OSDN Git Service

cxgb4: Check for kvzalloc allocation failure
authorYueHaibing <yuehaibing@huawei.com>
Tue, 22 May 2018 07:07:18 +0000 (15:07 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 May 2018 01:52:44 +0000 (21:52 -0400)
t4_prep_fw doesn't check for card_fw pointer before store the read data,
which could lead to a NULL pointer dereference if kvzalloc failed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

index 513e1d3..8405187 100644 (file)
@@ -4140,6 +4140,10 @@ static int adap_init0(struct adapter *adap)
                 * card
                 */
                card_fw = kvzalloc(sizeof(*card_fw), GFP_KERNEL);
+               if (!card_fw) {
+                       ret = -ENOMEM;
+                       goto bye;
+               }
 
                /* Get FW from from /lib/firmware/ */
                ret = request_firmware(&fw, fw_info->fw_mod_name,