netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net-wan: Add check for NULL for utdm in ucc_hdlc_probe
@ 2022-12-23 14:32 Ekaterina Esina
  2022-12-23 15:30 ` [lvc-project] " Alexey Khoroshilov
  2023-01-09 15:49 ` Christophe Leroy
  0 siblings, 2 replies; 3+ messages in thread
From: Ekaterina Esina @ 2022-12-23 14:32 UTC (permalink / raw)
  To: Zhao Qiang
  Cc: Ekaterina Esina, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev, linuxppc-dev, linux-kernel, lvc-project

If uhdlc_priv_tsa != 1 then utdm is not initialized.
And if ret != NULL then goto undo_uhdlc_init, where utdm is dereferenced.
Same if dev == NULL.

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

Signed-off-by: Ekaterina Esina <eesina@astralinux.ru>
---
 drivers/net/wan/fsl_ucc_hdlc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 22edea6ca4b8..2ddb0f71e648 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1243,7 +1243,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
 free_dev:
 	free_netdev(dev);
 undo_uhdlc_init:
-	iounmap(utdm->siram);
+	if (utdm != NULL) {
+		iounmap(utdm->siram);
+	}
 unmap_si_regs:
 	iounmap(utdm->si_regs);
 free_utdm:
-- 
2.30.2


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

* Re: [lvc-project] [PATCH] net-wan: Add check for NULL for utdm in ucc_hdlc_probe
  2022-12-23 14:32 [PATCH] net-wan: Add check for NULL for utdm in ucc_hdlc_probe Ekaterina Esina
@ 2022-12-23 15:30 ` Alexey Khoroshilov
  2023-01-09 15:49 ` Christophe Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Alexey Khoroshilov @ 2022-12-23 15:30 UTC (permalink / raw)
  To: Ekaterina Esina, Zhao Qiang
  Cc: lvc-project, netdev, linux-kernel, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linuxppc-dev, David S . Miller

On 23.12.2022 17:32, Ekaterina Esina wrote:
> If uhdlc_priv_tsa != 1 then utdm is not initialized.
> And if ret != NULL then goto undo_uhdlc_init, where utdm is dereferenced.
> Same if dev == NULL.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Ekaterina Esina <eesina@astralinux.ru>
> ---
>  drivers/net/wan/fsl_ucc_hdlc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
> index 22edea6ca4b8..2ddb0f71e648 100644
> --- a/drivers/net/wan/fsl_ucc_hdlc.c
> +++ b/drivers/net/wan/fsl_ucc_hdlc.c
> @@ -1243,7 +1243,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
>  free_dev:
>  	free_netdev(dev);
>  undo_uhdlc_init:
> -	iounmap(utdm->siram);
> +	if (utdm != NULL) {
> +		iounmap(utdm->siram);
> +	}
>  unmap_si_regs:
>  	iounmap(utdm->si_regs);
>  free_utdm:


But what is about iounmap(utdm->si_regs); that dereferences utdm a few
lines below?

--
Alexey


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

* Re: [PATCH] net-wan: Add check for NULL for utdm in ucc_hdlc_probe
  2022-12-23 14:32 [PATCH] net-wan: Add check for NULL for utdm in ucc_hdlc_probe Ekaterina Esina
  2022-12-23 15:30 ` [lvc-project] " Alexey Khoroshilov
@ 2023-01-09 15:49 ` Christophe Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe Leroy @ 2023-01-09 15:49 UTC (permalink / raw)
  To: Ekaterina Esina, Zhao Qiang
  Cc: lvc-project, netdev, linux-kernel, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linuxppc-dev, David S . Miller



Le 23/12/2022 à 15:32, Ekaterina Esina a écrit :
> [Vous ne recevez pas souvent de courriers de eesina@astralinux.ru. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> 
> If uhdlc_priv_tsa != 1 then utdm is not initialized.
> And if ret != NULL then goto undo_uhdlc_init, where utdm is dereferenced.
> Same if dev == NULL.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Ekaterina Esina <eesina@astralinux.ru>
> ---
>   drivers/net/wan/fsl_ucc_hdlc.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
> index 22edea6ca4b8..2ddb0f71e648 100644
> --- a/drivers/net/wan/fsl_ucc_hdlc.c
> +++ b/drivers/net/wan/fsl_ucc_hdlc.c
> @@ -1243,7 +1243,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
>   free_dev:
>          free_netdev(dev);
>   undo_uhdlc_init:
> -       iounmap(utdm->siram);
> +       if (utdm != NULL) {
> +               iounmap(utdm->siram);
> +       }

If utdm being NULL is a problem here, isn't it also a problem in the 
iounmap below ?


>   unmap_si_regs:
>          iounmap(utdm->si_regs);
>   free_utdm:
> --
> 2.30.2
> 

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

end of thread, other threads:[~2023-01-09 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 14:32 [PATCH] net-wan: Add check for NULL for utdm in ucc_hdlc_probe Ekaterina Esina
2022-12-23 15:30 ` [lvc-project] " Alexey Khoroshilov
2023-01-09 15:49 ` Christophe Leroy

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