Skip to contentSkip to conversation

qed: fix possible uninit pointer read in qed_mcp_nvm_info_populate()

PATCH Applied Gianfranco Trad 3 participants 3 messages Dec 15, 2024 – Dec 17, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qed: fix possible uninit pointer read in qed_mcp_nvm_info_populate()

Coverity reports an uninit pointer read in qed_mcp_nvm_info_populate(). If EOPNOTSUPP is returned from qed_mcp_bist_nvm_get_num_images() ensure nvm_info.num_images is set to 0 to avoid possible uninit assignment to p_hwfn->nvm_info.image_att later on in out label.

---
Notes:
- Changes in v2: set nvm_info.num_images to 0 before goto out.
- Link to v1: https://lore.kernel.org/all/[email protected]/

 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/qlogic/qed/qed_mcp.c +1 -0
index b45efc272fdb..c7f497c36f66 100644
@@ -3358,6 +3358,7 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
 					     p_ptt, &nvm_info.num_images);
 	if (rc == -EOPNOTSUPP) {
 		DP_INFO(p_hwfn, "DRV_MSG_CODE_BIST_TEST is not supported\n");
+		nvm_info.num_images = 0;
 		goto out;
 	} else if (rc || !nvm_info.num_images) {
 		DP_ERR(p_hwfn, "Failed getting number of images\n");
Signature · 1 line
2.43.0
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Gianfranco Trad

Coverity reports an uninit pointer read in qed_mcp_nvm_info_populate(). If EOPNOTSUPP is returned from qed_mcp_bist_nvm_get_num_images() ensure nvm_info.num_images is set to 0 to avoid possible uninit assignment to p_hwfn->nvm_info.image_att later on in out label.

Quoted 7 lines

---
Notes:
- Changes in v2: set nvm_info.num_images to 0 before goto out.
- Link to v1: https://lore.kernel.org/all/[email protected]/

Thanks for the update.

#2 lore raw
In reply to Gianfranco Trad
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Sun, 15 Dec 2024 02:17:34 +0100 you wrote:

Coverity reports an uninit pointer read in qed_mcp_nvm_info_populate(). If EOPNOTSUPP is returned from qed_mcp_bist_nvm_get_num_images() ensure nvm_info.num_images is set to 0 to avoid possible uninit assignment to p_hwfn->nvm_info.image_att later on in out label.

[...]

Here is the summary with links:
- [v2] qed: fix possible uninit pointer read in qed_mcp_nvm_info_populate()

    https://git.kernel.org/netdev/net/c/7ed2d9158877

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html