netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qed: fix uninit pointer read in qed_mcp_nvm_info_populate()
@ 2024-12-11 13:40 Gianfranco Trad
  2024-12-12 17:04 ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Gianfranco Trad @ 2024-12-11 13:40 UTC (permalink / raw)
  To: manishc, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, skhan, Gianfranco Trad

Coverity reports an uninit pointer read in qed_mcp_nvm_info_populate().
If qed_mcp_bist_nvm_get_num_images() returns -EOPNOTSUPP, this leads to
jump to label out with nvm_info.image_att being uninit while assigning it
to p_hwfn->nvm_info.image_att.
Add check on rc against -EOPNOTSUPP to avoid such uninit pointer read.

Closes: https://scan5.scan.coverity.com/#/project-view/63204/10063?selectedIssue=1636666
Signed-off-by: Gianfranco Trad <gianf.trad@gmail.com>
---
Note:
- Fixes: tag should be "7a0ea70da56e net/qed: allow old cards not supporting "num_images" to work" ?
  
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index b45efc272fdb..127943b39f61 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3387,7 +3387,7 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
 	}
 out:
 	/* Update hwfn's nvm_info */
-	if (nvm_info.num_images) {
+	if (nvm_info.num_images && rc != -EOPNOTSUPP) {
 		p_hwfn->nvm_info.num_images = nvm_info.num_images;
 		kfree(p_hwfn->nvm_info.image_att);
 		p_hwfn->nvm_info.image_att = nvm_info.image_att;
-- 
2.43.0


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

end of thread, other threads:[~2024-12-15  1:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 13:40 [PATCH] qed: fix uninit pointer read in qed_mcp_nvm_info_populate() Gianfranco Trad
2024-12-12 17:04 ` Simon Horman
2024-12-13 12:13   ` Gianfranco Trad
2024-12-13 13:31     ` Simon Horman
2024-12-15  1:11       ` Gianfranco Trad

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).