netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 net] sctp: handle invalid error codes without calling BUG()
@ 2023-06-09 11:04 Dan Carpenter
  2023-06-09 11:05 ` [PATCH 2/2 net] sctp: fix an error code in sctp_sf_eat_auth() Dan Carpenter
  2023-06-12  8:40 ` [PATCH 1/2 net] sctp: handle invalid error codes without calling BUG() patchwork-bot+netdevbpf
  0 siblings, 2 replies; 9+ messages in thread
From: Dan Carpenter @ 2023-06-09 11:04 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: Xin Long, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-sctp, netdev, kernel-janitors

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(-)

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;
 	}
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-12  8:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09 11:04 [PATCH 1/2 net] sctp: handle invalid error codes without calling BUG() Dan Carpenter
2023-06-09 11:05 ` [PATCH 2/2 net] sctp: fix an error code in sctp_sf_eat_auth() Dan Carpenter
2023-06-09 15:13   ` Xin Long
2023-06-09 16:41     ` Dan Carpenter
2023-06-09 23:04       ` Xin Long
2023-06-10  6:26         ` Jakub Kicinski
2023-06-10  6:28         ` Dan Carpenter
2023-06-10 18:27           ` Xin Long
2023-06-12  8:40 ` [PATCH 1/2 net] sctp: handle invalid error codes without calling BUG() patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).