diff mbox series

[1/2,net] sctp: handle invalid error codes without calling BUG()

Message ID 4629fee1-4c9f-4930-a210-beb7921fa5b3@moroto.mountain (mailing list archive)
State Accepted
Commit a0067dfcd9418fd3b0632bc59210d120d038a9c6
Delegated to: Netdev Maintainers
Headers show
Series [1/2,net] sctp: handle invalid error codes without calling BUG() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter June 9, 2023, 11:04 a.m. UTC
The sctp_sf_eat_auth() function is supposed to return enum sctp_disposition
values but if the call to sctp_ulpevent_make_authkey() fails, it returns
-ENOMEM.

This results in calling BUG() inside the sctp_side_effects() function.
Calling BUG() is an over reaction and not helpful.  Call WARN_ON_ONCE()
instead.

This code predates git.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
This is just from reviewing the code and not tested.

To be honest, the WARN_ON_ONCE() stack trace is not very helpful either
because it wouldn't include sctp_sf_eat_auth().  It's the best I can
think of though.

 net/sctp/sm_sideeffect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 12, 2023, 8:40 a.m. UTC | #1
Hello:

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

On Fri, 9 Jun 2023 14:04:43 +0300 you wrote:
> The sctp_sf_eat_auth() function is supposed to return enum sctp_disposition
> values but if the call to sctp_ulpevent_make_authkey() fails, it returns
> -ENOMEM.
> 
> This results in calling BUG() inside the sctp_side_effects() function.
> Calling BUG() is an over reaction and not helpful.  Call WARN_ON_ONCE()
> instead.
> 
> [...]

Here is the summary with links:
  - [1/2,net] sctp: handle invalid error codes without calling BUG()
    https://git.kernel.org/netdev/net/c/a0067dfcd941
  - [2/2,net] sctp: fix an error code in sctp_sf_eat_auth()
    https://git.kernel.org/netdev/net/c/75e6def3b267

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 7fbeb99d8d32..8c88045f26c6 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -1250,7 +1250,10 @@  static int sctp_side_effects(enum sctp_event_type event_type,
 	default:
 		pr_err("impossible disposition %d in state %d, event_type %d, event_id %d\n",
 		       status, state, event_type, subtype.chunk);
-		BUG();
+		error = status;
+		if (error >= 0)
+			error = -EINVAL;
+		WARN_ON_ONCE(1);
 		break;
 	}