Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ehea: Fix mem allocations which require page alignment

PAGE_SIZE allocations via slab are not guaranteed to be page-aligned. Fixed
all memory allocations where page alignment is required by firmware.

Signed-off-by: Thomas Klein <tklein@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Thomas Klein and committed by
David S. Miller
3faf2693 086c1b2c

+30 -30
+28 -28
drivers/net/ehea/ehea_main.c
··· 308 308 309 309 memset(stats, 0, sizeof(*stats)); 310 310 311 - cb2 = kzalloc(PAGE_SIZE, GFP_ATOMIC); 311 + cb2 = (void *)get_zeroed_page(GFP_ATOMIC); 312 312 if (!cb2) { 313 313 ehea_error("no mem for cb2"); 314 314 goto out; ··· 341 341 stats->rx_packets = rx_packets; 342 342 343 343 out_herr: 344 - kfree(cb2); 344 + free_page((unsigned long)cb2); 345 345 out: 346 346 return stats; 347 347 } ··· 915 915 struct hcp_ehea_port_cb0 *cb0; 916 916 917 917 /* may be called via ehea_neq_tasklet() */ 918 - cb0 = kzalloc(PAGE_SIZE, GFP_ATOMIC); 918 + cb0 = (void *)get_zeroed_page(GFP_ATOMIC); 919 919 if (!cb0) { 920 920 ehea_error("no mem for cb0"); 921 921 ret = -ENOMEM; ··· 996 996 out_free: 997 997 if (ret || netif_msg_probe(port)) 998 998 ehea_dump(cb0, sizeof(*cb0), "ehea_sense_port_attr"); 999 - kfree(cb0); 999 + free_page((unsigned long)cb0); 1000 1000 out: 1001 1001 return ret; 1002 1002 } ··· 1007 1007 u64 hret; 1008 1008 int ret = 0; 1009 1009 1010 - cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL); 1010 + cb4 = (void *)get_zeroed_page(GFP_KERNEL); 1011 1011 if (!cb4) { 1012 1012 ehea_error("no mem for cb4"); 1013 1013 ret = -ENOMEM; ··· 1075 1075 if (!prop_carrier_state || (port->phy_link == EHEA_PHY_LINK_UP)) 1076 1076 netif_carrier_on(port->netdev); 1077 1077 1078 - kfree(cb4); 1078 + free_page((unsigned long)cb4); 1079 1079 out: 1080 1080 return ret; 1081 1081 } ··· 1302 1302 struct hcp_ehea_port_cb0 *cb0; 1303 1303 1304 1304 ret = -ENOMEM; 1305 - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); 1305 + cb0 = (void *)get_zeroed_page(GFP_KERNEL); 1306 1306 if (!cb0) 1307 1307 goto out; 1308 1308 ··· 1338 1338 ret = 0; 1339 1339 1340 1340 out_free: 1341 - kfree(cb0); 1341 + free_page((unsigned long)cb0); 1342 1342 out: 1343 1343 return ret; 1344 1344 } ··· 1748 1748 goto out; 1749 1749 } 1750 1750 1751 - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); 1751 + cb0 = (void *)get_zeroed_page(GFP_KERNEL); 1752 1752 if (!cb0) { 1753 1753 ehea_error("no mem for cb0"); 1754 1754 ret = -ENOMEM; ··· 1793 1793 ehea_update_bcmc_registrations(); 1794 1794 spin_unlock(&ehea_bcmc_regs.lock); 1795 1795 out_free: 1796 - kfree(cb0); 1796 + free_page((unsigned long)cb0); 1797 1797 out: 1798 1798 return ret; 1799 1799 } ··· 1817 1817 if ((enable && port->promisc) || (!enable && !port->promisc)) 1818 1818 return; 1819 1819 1820 - cb7 = kzalloc(PAGE_SIZE, GFP_ATOMIC); 1820 + cb7 = (void *)get_zeroed_page(GFP_ATOMIC); 1821 1821 if (!cb7) { 1822 1822 ehea_error("no mem for cb7"); 1823 1823 goto out; ··· 1836 1836 1837 1837 port->promisc = enable; 1838 1838 out: 1839 - kfree(cb7); 1839 + free_page((unsigned long)cb7); 1840 1840 return; 1841 1841 } 1842 1842 ··· 2217 2217 2218 2218 port->vgrp = grp; 2219 2219 2220 - cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL); 2220 + cb1 = (void *)get_zeroed_page(GFP_KERNEL); 2221 2221 if (!cb1) { 2222 2222 ehea_error("no mem for cb1"); 2223 2223 goto out; ··· 2228 2228 if (hret != H_SUCCESS) 2229 2229 ehea_error("modify_ehea_port failed"); 2230 2230 2231 - kfree(cb1); 2231 + free_page((unsigned long)cb1); 2232 2232 out: 2233 2233 return; 2234 2234 } ··· 2241 2241 int index; 2242 2242 u64 hret; 2243 2243 2244 - cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL); 2244 + cb1 = (void *)get_zeroed_page(GFP_KERNEL); 2245 2245 if (!cb1) { 2246 2246 ehea_error("no mem for cb1"); 2247 2247 goto out; ··· 2262 2262 if (hret != H_SUCCESS) 2263 2263 ehea_error("modify_ehea_port failed"); 2264 2264 out: 2265 - kfree(cb1); 2265 + free_page((unsigned long)cb1); 2266 2266 return; 2267 2267 } 2268 2268 ··· 2276 2276 2277 2277 vlan_group_set_device(port->vgrp, vid, NULL); 2278 2278 2279 - cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL); 2279 + cb1 = (void *)get_zeroed_page(GFP_KERNEL); 2280 2280 if (!cb1) { 2281 2281 ehea_error("no mem for cb1"); 2282 2282 goto out; ··· 2297 2297 if (hret != H_SUCCESS) 2298 2298 ehea_error("modify_ehea_port failed"); 2299 2299 out: 2300 - kfree(cb1); 2300 + free_page((unsigned long)cb1); 2301 2301 return; 2302 2302 } 2303 2303 ··· 2309 2309 u64 dummy64 = 0; 2310 2310 struct hcp_modify_qp_cb0 *cb0; 2311 2311 2312 - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); 2312 + cb0 = (void *)get_zeroed_page(GFP_KERNEL); 2313 2313 if (!cb0) { 2314 2314 ret = -ENOMEM; 2315 2315 goto out; ··· 2372 2372 2373 2373 ret = 0; 2374 2374 out: 2375 - kfree(cb0); 2375 + free_page((unsigned long)cb0); 2376 2376 return ret; 2377 2377 } 2378 2378 ··· 2664 2664 u64 dummy64 = 0; 2665 2665 u16 dummy16 = 0; 2666 2666 2667 - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); 2667 + cb0 = (void *)get_zeroed_page(GFP_KERNEL); 2668 2668 if (!cb0) { 2669 2669 ret = -ENOMEM; 2670 2670 goto out; ··· 2716 2716 2717 2717 ret = 0; 2718 2718 out: 2719 - kfree(cb0); 2719 + free_page((unsigned long)cb0); 2720 2720 2721 2721 return ret; 2722 2722 } ··· 2766 2766 u64 dummy64 = 0; 2767 2767 u16 dummy16 = 0; 2768 2768 2769 - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); 2769 + cb0 = (void *)get_zeroed_page(GFP_KERNEL); 2770 2770 if (!cb0) { 2771 2771 ret = -ENOMEM; 2772 2772 goto out; ··· 2819 2819 ehea_refill_rq3(pr, 0); 2820 2820 } 2821 2821 out: 2822 - kfree(cb0); 2822 + free_page((unsigned long)cb0); 2823 2823 2824 2824 return ret; 2825 2825 } ··· 2950 2950 u64 hret; 2951 2951 int ret; 2952 2952 2953 - cb = kzalloc(PAGE_SIZE, GFP_KERNEL); 2953 + cb = (void *)get_zeroed_page(GFP_KERNEL); 2954 2954 if (!cb) { 2955 2955 ret = -ENOMEM; 2956 2956 goto out; ··· 2967 2967 ret = 0; 2968 2968 2969 2969 out_herr: 2970 - kfree(cb); 2970 + free_page((unsigned long)cb); 2971 2971 out: 2972 2972 return ret; 2973 2973 } ··· 2981 2981 *jumbo = 0; 2982 2982 2983 2983 /* (Try to) enable *jumbo frames */ 2984 - cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL); 2984 + cb4 = (void *)get_zeroed_page(GFP_KERNEL); 2985 2985 if (!cb4) { 2986 2986 ehea_error("no mem for cb4"); 2987 2987 ret = -ENOMEM; ··· 3009 3009 } else 3010 3010 ret = -EINVAL; 3011 3011 3012 - kfree(cb4); 3012 + free_page((unsigned long)cb4); 3013 3013 } 3014 3014 out: 3015 3015 return ret;
+2 -2
drivers/net/ehea/ehea_qmr.c
··· 1005 1005 unsigned long ret; 1006 1006 u64 *rblock; 1007 1007 1008 - rblock = kzalloc(PAGE_SIZE, GFP_KERNEL); 1008 + rblock = (void *)get_zeroed_page(GFP_KERNEL); 1009 1009 if (!rblock) { 1010 1010 ehea_error("Cannot allocate rblock memory."); 1011 1011 return; ··· 1022 1022 else 1023 1023 ehea_error("Error data could not be fetched: %llX", res_handle); 1024 1024 1025 - kfree(rblock); 1025 + free_page((unsigned long)rblock); 1026 1026 }