diff mbox series

[next] net: hns3: Fix return of uninitialized variable ret

Message ID 20210521100146.42980-1-colin.king@canonical.com (mailing list archive)
State Accepted
Commit 030c8198d744e4149da57bd2a73b87aa6a8aa272
Delegated to: Netdev Maintainers
Headers show
Series [next] net: hns3: Fix return of uninitialized variable ret | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 5 maintainers not CCed: moyufeng@huawei.com shenjian15@huawei.com zhangjiaran@huawei.com huangguangbin2@huawei.com liuyonglong@huawei.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: 'unitialized' may be misspelled - perhaps 'uninitialized'?
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Colin King May 21, 2021, 10:01 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

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")
Fixes: b5a0b70d77b9 ("net: hns3: refactor dump fd tcam of debugfs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

patchwork-bot+netdevbpf@kernel.org May 21, 2021, 9 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri, 21 May 2021 11:01:46 +0100 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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.
> 
> [...]

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
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index dd9eb6e6f5a7..0b7c6838d905 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -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];