[v5] drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close()
Message ID | 20230919142502.13898-1-adiupina@astralinux.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3439343vqi; Tue, 19 Sep 2023 07:39:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqXaR2G5feMj5IEZCdaMjDr8HxagIItynYerH65cAXSstUnP0zRPJneTIFpguPLLaE+YXy X-Received: by 2002:a05:6a21:3295:b0:153:39d9:56f8 with SMTP id yt21-20020a056a21329500b0015339d956f8mr3570288pzb.15.1695134391495; Tue, 19 Sep 2023 07:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695134391; cv=none; d=google.com; s=arc-20160816; b=VRILVdpHeRDL3/Sye7VgI98HUx+iLVv/BS69r9VzKdE+rJXSqGBjqqAzvaE/BQCg8f Migs2LnFYgPZs+MnyeINxy9ZGTQN1sj7MsOizbvW/+Vj3MiE7NwNQ40vjDc6tPZDaJ4W SqhTRFh0izvqrxAUzva/mzkv33N0OyIp41fnV4crT5lUiL8JBhgGGP7tHGbogN/g5AK+ tXpj7b07KuO1r+0lXq9wRPqt6N/96ZOgIti/Yl3zupXNUZLWzcxO8nn15g2mT+MnumM5 9ohsdEUZKOAmRsMaebAcsfrnjJRSjDIgOLtvCg/5DYvvPET+J2LYocXiUlplZdz0FpoA 2/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5aYD7li1p+iF0CEBwQEPWpG7BKOUJ5HEDZwGDfhkyi4=; fh=ETlTW8x4AwHin9MCjlsnKJrEnnw980UwsThD4d/F+sg=; b=wzQ9iCTLwhHLuEaxjQYKAhFa1oFIa7jLj1kfnCg8qdtjh7yQsKG9u/JgHcb3AQ+HBo aKkgpzoot2J90/otABfwVPU+8zpfUB7JcaH34L2B/8a6xjbZYkJ0rkpmslMSsETqAcbi JIjJ3LNPmJ9zKAwaxmjNim+okRhrBRzbXV4jaBQIQxof0skHaJHplAwOel9p75BYOEiw t+IaNcpbfoVM3csFyJQuUiPXbzapJDTzeeab29P1ZBz1Z4hSYK3DErVjglyy2TksckGU TK+BdmrZqguBKP0q8cz9C7HpBx1q1QydS2UV5v9ON3ZQzpYs+cVnc/CSh8f1DTgdpALl rd7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id v191-20020a6389c8000000b005775e2f160fsi325181pgd.667.2023.09.19.07.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:39:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0632382DFD16; Tue, 19 Sep 2023 07:25:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232686AbjISOZi (ORCPT <rfc822;toshivichauhan@gmail.com> + 26 others); Tue, 19 Sep 2023 10:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbjISOZ0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 19 Sep 2023 10:25:26 -0400 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 329F9100; Tue, 19 Sep 2023 07:25:16 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id CF242186686B; Tue, 19 Sep 2023 17:25:12 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id txwk927cRQHZ; Tue, 19 Sep 2023 17:25:12 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 72C471866AFE; Tue, 19 Sep 2023 17:25:12 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HIkNsWFKyl_9; Tue, 19 Sep 2023 17:25:12 +0300 (MSK) Received: from rbta-msk-lt-302690.astralinux.ru (unknown [10.177.235.105]) by mail.astralinux.ru (Postfix) with ESMTPSA id DE370186681B; Tue, 19 Sep 2023 17:25:10 +0300 (MSK) From: Alexandra Diupina <adiupina@astralinux.ru> To: Zhao Qiang <qiang.zhao@nxp.com> Cc: Alexandra Diupina <adiupina@astralinux.ru>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v5] drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close() Date: Tue, 19 Sep 2023 17:25:02 +0300 Message-Id: <20230919142502.13898-1-adiupina@astralinux.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <c1437313a3fea94a66d33f7bf97f363c77838359.camel@redhat.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 19 Sep 2023 07:25:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777477239951372170 X-GMAIL-MSGID: 1777477239951372170 |
Series |
[v5] drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close()
|
|
Commit Message
Alexandra Diupina
Sept. 19, 2023, 2:25 p.m. UTC
Process the result of hdlc_open() and call uhdlc_close()
in case of an error. It is necessary to pass the error
code up the control flow, similar to a possible
error in request_irq().
Also add a hdlc_close() call to the uhdlc_close()
because the comment to hdlc_close() says it must be called
by the hardware driver when the HDLC device is being closed
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC")
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
---
v5: do some refactoring as Paolo Abeni <pabeni@redhat.com> and
Christophe Leroy <christophe.leroy@csgroup.eu> suggested
v4: undo all the things done prior to hdlc_open() as
Jakub Kicinski <kuba@kernel.org> suggested,
add hdlc_close() call to the uhdlc_close() to match the function comment,
add uhdlc_close() declaration to the top of the file not to put the
uhdlc_close() function definition before uhdlc_open()
v3: Fix the commits tree
v2: Remove the 'rc' variable (stores the return value of the
hdlc_open()) as Christophe Leroy <christophe.leroy@csgroup.eu> suggested
drivers/net/wan/fsl_ucc_hdlc.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Comments
Le 19/09/2023 à 16:25, Alexandra Diupina a écrit : > Process the result of hdlc_open() and call uhdlc_close() > in case of an error. It is necessary to pass the error > code up the control flow, similar to a possible > error in request_irq(). > Also add a hdlc_close() call to the uhdlc_close() > because the comment to hdlc_close() says it must be called > by the hardware driver when the HDLC device is being closed > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC") > Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> > --- > v5: do some refactoring as Paolo Abeni <pabeni@redhat.com> and > Christophe Leroy <christophe.leroy@csgroup.eu> suggested > v4: undo all the things done prior to hdlc_open() as > Jakub Kicinski <kuba@kernel.org> suggested, > add hdlc_close() call to the uhdlc_close() to match the function comment, > add uhdlc_close() declaration to the top of the file not to put the > uhdlc_close() function definition before uhdlc_open() > v3: Fix the commits tree > v2: Remove the 'rc' variable (stores the return value of the > hdlc_open()) as Christophe Leroy <christophe.leroy@csgroup.eu> suggested > drivers/net/wan/fsl_ucc_hdlc.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c > index 47c2ad7a3e42..fd50bb313b92 100644 > --- a/drivers/net/wan/fsl_ucc_hdlc.c > +++ b/drivers/net/wan/fsl_ucc_hdlc.c > @@ -34,6 +34,8 @@ > #define TDM_PPPOHT_SLIC_MAXIN > #define RX_BD_ERRORS (R_CD_S | R_OV_S | R_CR_S | R_AB_S | R_NO_S | R_LG_S) > > +static int uhdlc_close(struct net_device *dev); > + > static struct ucc_tdm_info utdm_primary_info = { > .uf_info = { > .tsa = 0, > @@ -708,6 +710,7 @@ static int uhdlc_open(struct net_device *dev) > hdlc_device *hdlc = dev_to_hdlc(dev); > struct ucc_hdlc_private *priv = hdlc->priv; > struct ucc_tdm *utdm = priv->utdm; > + int rc = 0; > > if (priv->hdlc_busy != 1) { > if (request_irq(priv->ut_info->uf_info.irq, > @@ -731,10 +734,13 @@ static int uhdlc_open(struct net_device *dev) > napi_enable(&priv->napi); > netdev_reset_queue(dev); > netif_start_queue(dev); > - hdlc_open(dev); > + > + rc = hdlc_open(dev); > + if (rc) > + uhdlc_close(dev); > } > > - return 0; > + return rc; > } > > static void uhdlc_memclean(struct ucc_hdlc_private *priv) > @@ -824,6 +830,8 @@ static int uhdlc_close(struct net_device *dev) > netdev_reset_queue(dev); > priv->hdlc_busy = 0; > > + hdlc_close(dev); > + > return 0; > } >
Hello: This patch was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Tue, 19 Sep 2023 17:25:02 +0300 you wrote: > Process the result of hdlc_open() and call uhdlc_close() > in case of an error. It is necessary to pass the error > code up the control flow, similar to a possible > error in request_irq(). > Also add a hdlc_close() call to the uhdlc_close() > because the comment to hdlc_close() says it must be called > by the hardware driver when the HDLC device is being closed > > [...] Here is the summary with links: - [v5] drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close() https://git.kernel.org/netdev/net/c/a59addacf899 You are awesome, thank you!
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 47c2ad7a3e42..fd50bb313b92 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -34,6 +34,8 @@ #define TDM_PPPOHT_SLIC_MAXIN #define RX_BD_ERRORS (R_CD_S | R_OV_S | R_CR_S | R_AB_S | R_NO_S | R_LG_S) +static int uhdlc_close(struct net_device *dev); + static struct ucc_tdm_info utdm_primary_info = { .uf_info = { .tsa = 0, @@ -708,6 +710,7 @@ static int uhdlc_open(struct net_device *dev) hdlc_device *hdlc = dev_to_hdlc(dev); struct ucc_hdlc_private *priv = hdlc->priv; struct ucc_tdm *utdm = priv->utdm; + int rc = 0; if (priv->hdlc_busy != 1) { if (request_irq(priv->ut_info->uf_info.irq, @@ -731,10 +734,13 @@ static int uhdlc_open(struct net_device *dev) napi_enable(&priv->napi); netdev_reset_queue(dev); netif_start_queue(dev); - hdlc_open(dev); + + rc = hdlc_open(dev); + if (rc) + uhdlc_close(dev); } - return 0; + return rc; } static void uhdlc_memclean(struct ucc_hdlc_private *priv) @@ -824,6 +830,8 @@ static int uhdlc_close(struct net_device *dev) netdev_reset_queue(dev); priv->hdlc_busy = 0; + hdlc_close(dev); + return 0; }