From patchwork Mon Dec 11 03:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13486596 X-Patchwork-Delegate: kuba@kernel.org Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 119109D; Sun, 10 Dec 2023 19:13:50 -0800 (PST) X-UUID: b0aed6746fa9462dbc846b22f61b057a-20231211 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:62e02d26-f187-4327-b2ae-62bc0e600995,IP:5,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:-15 X-CID-INFO: VERSION:1.1.33,REQID:62e02d26-f187-4327-b2ae-62bc0e600995,IP:5,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-15 X-CID-META: VersionHash:364b77b,CLOUDID:5c8e0a61-c89d-4129-91cb-8ebfae4653fc,B ulkID:231211111344YBK1WEVE,BulkQuantity:0,Recheck:0,SF:17|19|44|66|38|24|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: b0aed6746fa9462dbc846b22f61b057a-20231211 X-User: chentao@kylinos.cn Received: from vt.. [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1392175482; Mon, 11 Dec 2023 11:13:41 +0800 From: Kunwu Chan To: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: jacob.e.keller@intel.com, przemyslaw.kitszel@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan , Kunwu Chan Subject: [PATCH] igb: Add null pointer check to igb_set_fw_version Date: Mon, 11 Dec 2023 11:13:36 +0800 Message-Id: <20231211031336.235634-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Fixes: 1978d3ead82c ("intel: fix string truncation warnings") Cc: Kunwu Chan Signed-off-by: Kunwu Chan --- drivers/net/ethernet/intel/igb/igb_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index b2295caa2f0a..6838f6fccb80 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -3102,6 +3102,8 @@ void igb_set_fw_version(struct igb_adapter *adapter) break; } + if (!lbuf) + return; /* the truncate happens here if it doesn't fit */ strscpy(adapter->fw_version, lbuf, sizeof(adapter->fw_version)); kfree(lbuf);