diff mbox series

niu: Fix missing unwind goto in niu_alloc_channels()

Message ID 20230406063120.3626731-1-harshit.m.mogalapalli@oracle.com (mailing list archive)
State Accepted
Commit 8ce07be703456acb00e83d99f3b8036252c33b02
Delegated to: Netdev Maintainers
Headers show
Series niu: Fix missing unwind goto in niu_alloc_channels() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 20 this patch: 20
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Harshit Mogalapalli April 6, 2023, 6:31 a.m. UTC
Smatch reports: drivers/net/ethernet/sun/niu.c:4525
	niu_alloc_channels() warn: missing unwind goto?

If niu_rbr_fill() fails, then we are directly returning 'err' without
freeing the channels.

Fix this by changing direct return to a goto 'out_err'.

Fixes: a3138df9f20e ("[NIU]: Add Sun Neptune ethernet driver.")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is purely based on static analysis. Only compile tested.
---
 drivers/net/ethernet/sun/niu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman April 6, 2023, 2:30 p.m. UTC | #1
On Wed, Apr 05, 2023 at 11:31:18PM -0700, Harshit Mogalapalli wrote:
> Smatch reports: drivers/net/ethernet/sun/niu.c:4525
> 	niu_alloc_channels() warn: missing unwind goto?
> 
> If niu_rbr_fill() fails, then we are directly returning 'err' without
> freeing the channels.
> 
> Fix this by changing direct return to a goto 'out_err'.
> 
> Fixes: a3138df9f20e ("[NIU]: Add Sun Neptune ethernet driver.")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> This is purely based on static analysis. Only compile tested.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
patchwork-bot+netdevbpf@kernel.org April 7, 2023, 7:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed,  5 Apr 2023 23:31:18 -0700 you wrote:
> Smatch reports: drivers/net/ethernet/sun/niu.c:4525
> 	niu_alloc_channels() warn: missing unwind goto?
> 
> If niu_rbr_fill() fails, then we are directly returning 'err' without
> freeing the channels.
> 
> Fix this by changing direct return to a goto 'out_err'.
> 
> [...]

Here is the summary with links:
  - niu: Fix missing unwind goto in niu_alloc_channels()
    https://git.kernel.org/netdev/net/c/8ce07be70345

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index ab8b09a9ef61..7a2e76776297 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -4522,7 +4522,7 @@  static int niu_alloc_channels(struct niu *np)
 
 		err = niu_rbr_fill(np, rp, GFP_KERNEL);
 		if (err)
-			return err;
+			goto out_err;
 	}
 
 	tx_rings = kcalloc(num_tx_rings, sizeof(struct tx_ring_info),