diff mbox series

[v2] can: j1939: Replace WARN_ON_ONCE with netdev_warn_once() in j1939_sk_queue_activate_next_locked()

Message ID 20220729140609.980154-1-pchelkin@ispras.ru (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v2] can: j1939: Replace WARN_ON_ONCE with netdev_warn_once() in j1939_sk_queue_activate_next_locked() | expand

Checks

Context Check Description
netdev/tree_selection success Series ignored based on subject

Commit Message

Fedor Pchelkin July 29, 2022, 2:06 p.m. UTC
We should warn user-space that it is doing something wrong when trying to
activate sessions with identical parameters but WARN_ON_ONCE macro can not
be used here as it serves a different purpose.

So it would be good to replace it with netdev_warn_once() message.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
v1 -> v2: Used netdev_warn_once() instead of pr_warn_once()

 net/can/j1939/socket.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Oleksij Rempel July 29, 2022, 2:26 p.m. UTC | #1
On Fri, Jul 29, 2022 at 05:06:09PM +0300, Fedor Pchelkin wrote:
> We should warn user-space that it is doing something wrong when trying to
> activate sessions with identical parameters but WARN_ON_ONCE macro can not
> be used here as it serves a different purpose.
> 
> So it would be good to replace it with netdev_warn_once() message.
> 
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
> 
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>

> ---
> v1 -> v2: Used netdev_warn_once() instead of pr_warn_once()
> 
>  net/can/j1939/socket.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
> index f5ecfdcf57b2..09e1d78bd22c 100644
> --- a/net/can/j1939/socket.c
> +++ b/net/can/j1939/socket.c
> @@ -178,7 +178,10 @@ static void j1939_sk_queue_activate_next_locked(struct j1939_session *session)
>  	if (!first)
>  		return;
>  
> -	if (WARN_ON_ONCE(j1939_session_activate(first))) {
> +	if (j1939_session_activate(first)) {
> +		netdev_warn_once(first->priv->ndev,
> +						 "%s: 0x%p: Identical session is already activated.\n",
> +						 __func__, first);
>  		first->err = -EBUSY;
>  		goto activate_next;
>  	} else {
> -- 
> 2.25.1
> 
>
diff mbox series

Patch

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index f5ecfdcf57b2..09e1d78bd22c 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -178,7 +178,10 @@  static void j1939_sk_queue_activate_next_locked(struct j1939_session *session)
 	if (!first)
 		return;
 
-	if (WARN_ON_ONCE(j1939_session_activate(first))) {
+	if (j1939_session_activate(first)) {
+		netdev_warn_once(first->priv->ndev,
+						 "%s: 0x%p: Identical session is already activated.\n",
+						 __func__, first);
 		first->err = -EBUSY;
 		goto activate_next;
 	} else {