diff mbox series

fsl_ucc_hdlc: add a check of the return value from hdlc_open

Message ID 20230825143112.16184-1-adiupina@astralinux.ru (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series fsl_ucc_hdlc: add a check of the return value from hdlc_open | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1330 this patch: 1330
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
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 Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Alexandra Diupina Aug. 25, 2023, 2:31 p.m. UTC
Process the result of hold_open() and return it from
uhdlc_open() 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()

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>
---
 drivers/net/wan/fsl_ucc_hdlc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Christophe Leroy Aug. 26, 2023, 6:32 a.m. UTC | #1
Le 25/08/2023 à 16:31, Alexandra Diupina a écrit :
> [Vous ne recevez pas souvent de courriers de adiupina@astralinux.ru. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> 
> Process the result of hold_open() and return it from
> uhdlc_open() 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()
> 
> 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>
> ---
>   drivers/net/wan/fsl_ucc_hdlc.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
> index 47c2ad7a3e42..cdd9489c712e 100644
> --- a/drivers/net/wan/fsl_ucc_hdlc.c
> +++ b/drivers/net/wan/fsl_ucc_hdlc.c
> @@ -708,6 +708,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;

rc not usefull outside the block below, no point in having it at all.

> 
>          if (priv->hdlc_busy != 1) {
>                  if (request_irq(priv->ut_info->uf_info.irq,
> @@ -731,10 +732,12 @@ 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)
> +                       return rc;

Don't need that rc variable. Just do:

	return hdlc_open(dev);

>          }
> 
> -       return 0;
> +       return rc;

Change not needed, leave return 0 here.

>   }
> 
>   static void uhdlc_memclean(struct ucc_hdlc_private *priv)
> --
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 47c2ad7a3e42..cdd9489c712e 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -708,6 +708,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 +732,12 @@  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)
+			return rc;
 	}
 
-	return 0;
+	return rc;
 }
 
 static void uhdlc_memclean(struct ucc_hdlc_private *priv)