From 3faf2693bd6800c2521799f6a9ae174d9f080ed2 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Wed, 21 Jan 2009 14:45:33 -0800 Subject: [PATCH] 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 Signed-off-by: David S. Miller --- drivers/net/ehea/ehea_main.c | 56 ++++++++++++++++++++++---------------------- drivers/net/ehea/ehea_qmr.c | 4 ++-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index d0c2c4569f2..dfcdd7f21c7 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c @@ -308,7 +308,7 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev) memset(stats, 0, sizeof(*stats)); - cb2 = kzalloc(PAGE_SIZE, GFP_ATOMIC); + cb2 = (void *)get_zeroed_page(GFP_ATOMIC); if (!cb2) { ehea_error("no mem for cb2"); goto out; @@ -341,7 +341,7 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev) stats->rx_packets = rx_packets; out_herr: - kfree(cb2); + free_page((unsigned long)cb2); out: return stats; } @@ -915,7 +915,7 @@ int ehea_sense_port_attr(struct ehea_port *port) struct hcp_ehea_port_cb0 *cb0; /* may be called via ehea_neq_tasklet() */ - cb0 = kzalloc(PAGE_SIZE, GFP_ATOMIC); + cb0 = (void *)get_zeroed_page(GFP_ATOMIC); if (!cb0) { ehea_error("no mem for cb0"); ret = -ENOMEM; @@ -996,7 +996,7 @@ int ehea_sense_port_attr(struct ehea_port *port) out_free: if (ret || netif_msg_probe(port)) ehea_dump(cb0, sizeof(*cb0), "ehea_sense_port_attr"); - kfree(cb0); + free_page((unsigned long)cb0); out: return ret; } @@ -1007,7 +1007,7 @@ int ehea_set_portspeed(struct ehea_port *port, u32 port_speed) u64 hret; int ret = 0; - cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb4 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb4) { ehea_error("no mem for cb4"); ret = -ENOMEM; @@ -1075,7 +1075,7 @@ int ehea_set_portspeed(struct ehea_port *port, u32 port_speed) if (!prop_carrier_state || (port->phy_link == EHEA_PHY_LINK_UP)) netif_carrier_on(port->netdev); - kfree(cb4); + free_page((unsigned long)cb4); out: return ret; } @@ -1302,7 +1302,7 @@ static int ehea_configure_port(struct ehea_port *port) struct hcp_ehea_port_cb0 *cb0; ret = -ENOMEM; - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb0 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb0) goto out; @@ -1338,7 +1338,7 @@ static int ehea_configure_port(struct ehea_port *port) ret = 0; out_free: - kfree(cb0); + free_page((unsigned long)cb0); out: return ret; } @@ -1748,7 +1748,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa) goto out; } - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb0 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb0) { ehea_error("no mem for cb0"); ret = -ENOMEM; @@ -1793,7 +1793,7 @@ out_upregs: ehea_update_bcmc_registrations(); spin_unlock(&ehea_bcmc_regs.lock); out_free: - kfree(cb0); + free_page((unsigned long)cb0); out: return ret; } @@ -1817,7 +1817,7 @@ static void ehea_promiscuous(struct net_device *dev, int enable) if ((enable && port->promisc) || (!enable && !port->promisc)) return; - cb7 = kzalloc(PAGE_SIZE, GFP_ATOMIC); + cb7 = (void *)get_zeroed_page(GFP_ATOMIC); if (!cb7) { ehea_error("no mem for cb7"); goto out; @@ -1836,7 +1836,7 @@ static void ehea_promiscuous(struct net_device *dev, int enable) port->promisc = enable; out: - kfree(cb7); + free_page((unsigned long)cb7); return; } @@ -2217,7 +2217,7 @@ static void ehea_vlan_rx_register(struct net_device *dev, port->vgrp = grp; - cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb1 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb1) { ehea_error("no mem for cb1"); goto out; @@ -2228,7 +2228,7 @@ static void ehea_vlan_rx_register(struct net_device *dev, if (hret != H_SUCCESS) ehea_error("modify_ehea_port failed"); - kfree(cb1); + free_page((unsigned long)cb1); out: return; } @@ -2241,7 +2241,7 @@ static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) int index; u64 hret; - cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb1 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb1) { ehea_error("no mem for cb1"); goto out; @@ -2262,7 +2262,7 @@ static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) if (hret != H_SUCCESS) ehea_error("modify_ehea_port failed"); out: - kfree(cb1); + free_page((unsigned long)cb1); return; } @@ -2276,7 +2276,7 @@ static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) vlan_group_set_device(port->vgrp, vid, NULL); - cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb1 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb1) { ehea_error("no mem for cb1"); goto out; @@ -2297,7 +2297,7 @@ static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) if (hret != H_SUCCESS) ehea_error("modify_ehea_port failed"); out: - kfree(cb1); + free_page((unsigned long)cb1); return; } @@ -2309,7 +2309,7 @@ int ehea_activate_qp(struct ehea_adapter *adapter, struct ehea_qp *qp) u64 dummy64 = 0; struct hcp_modify_qp_cb0 *cb0; - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb0 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb0) { ret = -ENOMEM; goto out; @@ -2372,7 +2372,7 @@ int ehea_activate_qp(struct ehea_adapter *adapter, struct ehea_qp *qp) ret = 0; out: - kfree(cb0); + free_page((unsigned long)cb0); return ret; } @@ -2664,7 +2664,7 @@ int ehea_stop_qps(struct net_device *dev) u64 dummy64 = 0; u16 dummy16 = 0; - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb0 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb0) { ret = -ENOMEM; goto out; @@ -2716,7 +2716,7 @@ int ehea_stop_qps(struct net_device *dev) ret = 0; out: - kfree(cb0); + free_page((unsigned long)cb0); return ret; } @@ -2766,7 +2766,7 @@ int ehea_restart_qps(struct net_device *dev) u64 dummy64 = 0; u16 dummy16 = 0; - cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb0 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb0) { ret = -ENOMEM; goto out; @@ -2819,7 +2819,7 @@ int ehea_restart_qps(struct net_device *dev) ehea_refill_rq3(pr, 0); } out: - kfree(cb0); + free_page((unsigned long)cb0); return ret; } @@ -2950,7 +2950,7 @@ int ehea_sense_adapter_attr(struct ehea_adapter *adapter) u64 hret; int ret; - cb = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb = (void *)get_zeroed_page(GFP_KERNEL); if (!cb) { ret = -ENOMEM; goto out; @@ -2967,7 +2967,7 @@ int ehea_sense_adapter_attr(struct ehea_adapter *adapter) ret = 0; out_herr: - kfree(cb); + free_page((unsigned long)cb); out: return ret; } @@ -2981,7 +2981,7 @@ int ehea_get_jumboframe_status(struct ehea_port *port, int *jumbo) *jumbo = 0; /* (Try to) enable *jumbo frames */ - cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL); + cb4 = (void *)get_zeroed_page(GFP_KERNEL); if (!cb4) { ehea_error("no mem for cb4"); ret = -ENOMEM; @@ -3009,7 +3009,7 @@ int ehea_get_jumboframe_status(struct ehea_port *port, int *jumbo) } else ret = -EINVAL; - kfree(cb4); + free_page((unsigned long)cb4); } out: return ret; diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c index 49d766ebbcf..3747457f5e6 100644 --- a/drivers/net/ehea/ehea_qmr.c +++ b/drivers/net/ehea/ehea_qmr.c @@ -1005,7 +1005,7 @@ void ehea_error_data(struct ehea_adapter *adapter, u64 res_handle) unsigned long ret; u64 *rblock; - rblock = kzalloc(PAGE_SIZE, GFP_KERNEL); + rblock = (void *)get_zeroed_page(GFP_KERNEL); if (!rblock) { ehea_error("Cannot allocate rblock memory."); return; @@ -1022,5 +1022,5 @@ void ehea_error_data(struct ehea_adapter *adapter, u64 res_handle) else ehea_error("Error data could not be fetched: %llX", res_handle); - kfree(rblock); + free_page((unsigned long)rblock); } -- 2.11.4.GIT