netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] igb: Add null pointer check to igb_set_fw_version
@ 2023-12-11  3:13 Kunwu Chan
  2023-12-12 21:26 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Kunwu Chan @ 2023-12-11  3:13 UTC (permalink / raw)
  To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba, pabeni
  Cc: jacob.e.keller, przemyslaw.kitszel, intel-wired-lan, netdev,
	linux-kernel, Kunwu Chan, Kunwu Chan

kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.

Fixes: 1978d3ead82c ("intel: fix string truncation warnings")
Cc: Kunwu Chan <kunwu.chan@hotmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 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);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-14  2:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-11  3:13 [PATCH] igb: Add null pointer check to igb_set_fw_version Kunwu Chan
2023-12-12 21:26 ` Jakub Kicinski
2023-12-14  2:44   ` Kunwu Chan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).