From: YueHaibing Date: Tue, 22 May 2018 07:07:18 +0000 (+0800) Subject: cxgb4: Check for kvzalloc allocation failure X-Git-Tag: for-linus-20180616~56^2~151 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=d624613e422d9bda9e4f066281b1f178ed51f0b1;p=linux-block.git cxgb4: Check for kvzalloc allocation failure 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 Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 513e1d356384..8405187f8e3f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -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,