net: hns3: Fix return of uninitialized variable ret
Subsystems (5)
PATCH 1/1 net: hns3: Fix return of uninitialized variable ret
From: Colin Ian King <[email protected]>
In the unlikely event that rule_cnt is zero the variable ret is not assigned a value and function hclge_dbg_dump_fd_tcam can end up returning an unitialized value in ret. Fix this by explicitly setting ret to zero before the for-loop.
Addresses-Coverity: ("Uninitialized scalar variable")
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +1 -0
@@ -1519,6 +1519,7 @@ static int hclge_dbg_dump_fd_tcam(struct hclge_dev *hdev, char *buf, int len) goto out; } + ret =0 ;for (i =0 ; i < rule_cnt; i++) { tcam_msg.stage =HCLGE_FD_STAGE_1 ; tcam_msg.loc = rule_locs[i];
Signature · 1 line
2.31.1
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Fri, 21 May 2021 11:01:46 +0100 you wrote:
From: Colin Ian King <[email protected]>
In the unlikely event that
rule_cntis zero the variable ret is not assigned a value and functionhclge_dbg_dump_fd_tcamcan end up returning an unitialized value in ret. Fix this by explicitly setting ret to zero before the for-loop.[...]
Here is the summary with links:
- [next] net: hns3: Fix return of uninitialized variable ret
https://git.kernel.org/netdev/net-next/c/030c8198d744
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html