From patchwork Mon Dec 11 02:59:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13486579 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 0327ECE; Sun, 10 Dec 2023 18:59:49 -0800 (PST) X-UUID: 0b105c8e154d4308be340be35614f20c-20231211 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:19a20f34-c316-4582-9f89-476ca1073edf,IP:5,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-10 X-CID-INFO: VERSION:1.1.33,REQID:19a20f34-c316-4582-9f89-476ca1073edf,IP:5,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:-10 X-CID-META: VersionHash:364b77b,CLOUDID:931283fd-4a48-46e2-b946-12f04f20af8c,B ulkID:231211105935IA61I4Z6,BulkQuantity:0,Recheck:0,SF:38|24|17|19|44|66|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_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS X-UUID: 0b105c8e154d4308be340be35614f20c-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 1052257917; Mon, 11 Dec 2023 10:59:34 +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] iavf: Fix null pointer dereference in iavf_print_link_message Date: Mon, 11 Dec 2023 10:59:27 +0800 Message-Id: <20231211025927.233449-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/iavf/iavf_virtchnl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c index 64c4443dbef9..1b50d351f28b 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -1444,6 +1444,8 @@ static void iavf_print_link_message(struct iavf_adapter *adapter) speed = kasprintf(GFP_KERNEL, "%d Mbps", link_speed_mbps); } + if (!speed) + return; netdev_info(netdev, "NIC Link is Up Speed is %s Full Duplex\n", speed); kfree(speed); }