From patchwork Fri Jul 29 14:36:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fedor Pchelkin X-Patchwork-Id: 12932476 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1C2CC19F2B for ; Fri, 29 Jul 2022 14:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237227AbiG2OhV (ORCPT ); Fri, 29 Jul 2022 10:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237203AbiG2OhR (ORCPT ); Fri, 29 Jul 2022 10:37:17 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A2D7D7A0; Fri, 29 Jul 2022 07:37:14 -0700 (PDT) Received: from localhost.localdomain (unknown [95.31.173.239]) by mail.ispras.ru (Postfix) with ESMTPSA id E259C4076263; Fri, 29 Jul 2022 14:37:10 +0000 (UTC) From: Fedor Pchelkin To: Robin van der Gracht , Oleksij Rempel Cc: Fedor Pchelkin , kernel@pengutronix.de, Oliver Hartkopp , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , ldv-project@linuxtesting.org, Oleksij Rempel Subject: [PATCH v2] can: j1939: Replace WARN_ON_ONCE with netdev_warn_once() in j1939_sk_queue_activate_next_locked() Date: Fri, 29 Jul 2022 17:36:55 +0300 Message-Id: <20220729143655.1108297-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220729142634.GD10850@pengutronix.de> References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Signed-off-by: Alexey Khoroshilov Acked-by: Oleksij Rempel --- 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 {