From: Rajesh Borundia Date: Tue, 2 Apr 2013 05:34:40 +0000 (+0000) Subject: qlcnic: Fix potential NULL dereference X-Git-Tag: v3.10-rc1~120^2~250 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=d8fe3436df256ce48d953dc342ac114e6e368476;p=linux.git qlcnic: Fix potential NULL dereference [net-next:master 301/302] drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c:563 qlcnic_set_multi() error: potential null dereference 'cur'. (kzalloc returns null) o Break out of the loop after memory allocation failure. Program all the MAC addresses that were cached in the return path. Reported-by: kbuild test robot Signed-off-by: Rajesh Borundia Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c index ddc130b23378..253b3ac16046 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c @@ -560,6 +560,8 @@ void qlcnic_set_multi(struct net_device *netdev) netdev_for_each_mc_addr(ha, netdev) { cur = kzalloc(sizeof(struct qlcnic_mac_list_s), GFP_ATOMIC); + if (cur == NULL) + break; memcpy(cur->mac_addr, ha->addr, ETH_ALEN); list_add_tail(&cur->list, &adapter->vf_mc_list);