Skip to contentSkip to conversation

net: airoha: Fix variable shadowing in airoha_ppe_flush_sram_entries()

PATCH In review Wayen.Yan 2 participants 2 messages Jun 11 – Jun 12

Subsystems (4)
lore
Share & tools
lore

Wayen.Yan

author
#0 lore raw

PATCH 1/1 net: airoha: Fix variable shadowing in airoha_ppe_flush_sram_entries()

In airoha_ppe_flush_sram_entries(), the inner "int err" declaration shadows the outer "err" variable. When airoha_ppe_foe_commit_sram_entry() fails and the loop breaks, the function returns the outer err which is always 0, silently swallowing the error.

Remove the inner declaration so the assignment writes to the outer variable and errors are properly propagated.

Fixes 620d7b91aadb ("net: airoha: ppe: Flush PPE SRAM table during PPE setup")
---
 drivers/net/ethernet/airoha/airoha_ppe.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/airoha/airoha_ppe.c +0 -2
index 5c9dff6..2b849d4 100644
@@ -1333,8 +1333,6 @@ static int airoha_ppe_flush_sram_entries(struct airoha_ppe *ppe)
 	int i, err = 0;
 
 	for (i = 0; i < sram_num_entries; i++) {
-		int err;
-
 		memset(&hwe[i], 0, sizeof(*hwe));
 		err = airoha_ppe_foe_commit_sram_entry(ppe, i);
 		if (err)
Signature · 1 line
2.51.0
maintainer
#1 lore raw
Quoted 19 lines

In airoha_ppe_flush_sram_entries(), the inner "int err" declaration shadows the outer "err" variable. When airoha_ppe_foe_commit_sram_entry() fails and the loop breaks, the function returns the outer err which is always 0, silently swallowing the error.

Remove the inner declaration so the assignment writes to the outer variable and errors are properly propagated.

Fixes 620d7b91aadb ("net: airoha: ppe: Flush PPE SRAM table during PPE setup")
---
 drivers/net/ethernet/airoha/airoha_ppe.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/airoha/airoha_ppe.c +0 -0
index 5c9dff6..2b849d4 100644

drivers/net/ethernet/airoha/airoha_ppe.c static int airoha_ppe_flush_sram_entries(struct airoha_ppe *ppe) · line 1338

Quoted 8 lines
drivers/net/ethernet/airoha/airoha_ppe.c +0 -2
@@ -1333,8 +1333,6 @@ static int airoha_ppe_flush_sram_entries(struct airoha_ppe *ppe)
 	int i, err = 0;
 
 	for (i = 0; i < sram_num_entries; i++) {
-		int err;
-
 		memset(&hwe[i], 0, sizeof(*hwe));
 		err = airoha_ppe_foe_commit_sram_entry(ppe, i);
 		if (err)

I guess we can drop the outer err and just return here in case of error. What do you think?

Regards,
Lorenzo

Quoted 4 lines
Signature · 1 line
2.51.0