* [PATCH v2] net: wan: Add checks for NULL. 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.
@ 2023-01-10 11:47 Esina Ekaterina
2023-01-11 4:44 ` Jakub Kicinski
0 siblings, 1 reply; 7+ messages in thread
From: Esina Ekaterina @ 2023-01-10 11:47 UTC (permalink / raw)
To: Zhao Qiang
Cc: netdev, linux-kernel, Eric Dumazet, Esina Ekaterina,
Jakub Kicinski, Paolo Abeni, linuxppc-dev, David S . Miller
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Esina Ekaterina <eesina@astralinux.ru>
v2: Add check for NULL for unmap_si_regs
---
drivers/net/wan/fsl_ucc_hdlc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 22edea6ca4b8..ed7886bde727 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1243,9 +1243,13 @@ 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);
+ if (utdm != NULL) {
+ iounmap(utdm->si_regs);
+ }
free_utdm:
if (uhdlc_priv->tsa)
kfree(utdm);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] net: wan: Add checks for NULL. 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.
2023-01-10 11:47 [PATCH v2] net: wan: Add checks for NULL. 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 Esina Ekaterina
@ 2023-01-11 4:44 ` Jakub Kicinski
2023-01-11 9:05 ` [PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs Esina Ekaterina
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2023-01-11 4:44 UTC (permalink / raw)
To: Esina Ekaterina
Cc: netdev, linux-kernel, Eric Dumazet, Paolo Abeni, linuxppc-dev,
David S . Miller, Zhao Qiang
On Tue, 10 Jan 2023 14:47:45 +0300 Esina Ekaterina wrote:
> Subject: [PATCH v2] net: wan: Add checks for NULL. 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: Esina Ekaterina <eesina@astralinux.ru>
>
> v2: Add check for NULL for unmap_si_regs
> ---
The format of your commit is wrong. You should make the commit message
look like this in git:
net: wan: Add checks for NULL
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: Esina Ekaterina <eesina@astralinux.ru>
---
v2: Add check for NULL for unmap_si_regs
But the first line (subject) is still not specific enough.
Refer to the bug that's being fixed, not how it's fixed.
Also no braces needed around single-line if blocks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
2023-01-11 4:44 ` Jakub Kicinski
@ 2023-01-11 9:05 ` Esina Ekaterina
2023-01-11 18:28 ` Jakub Kicinski
0 siblings, 1 reply; 7+ messages in thread
From: Esina Ekaterina @ 2023-01-11 9:05 UTC (permalink / raw)
To: Zhao Qiang
Cc: lvc-project, netdev, linux-kernel, Eric Dumazet, Esina Ekaterina,
Jakub Kicinski, Paolo Abeni, linuxppc-dev, David S . Miller
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: Esina Ekaterina <eesina@astralinux.ru>
---
v3: Remove braces
v2: Add check for NULL for unmap_si_regs
---
drivers/net/wan/fsl_ucc_hdlc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 22edea6ca4b8..8166708c7190 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1243,9 +1243,11 @@ 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);
+ if (utdm != NULL)
+ iounmap(utdm->si_regs);
free_utdm:
if (uhdlc_priv->tsa)
kfree(utdm);
--
2.39.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
2023-01-11 9:05 ` [PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs Esina Ekaterina
@ 2023-01-11 18:28 ` Jakub Kicinski
2023-01-11 19:55 ` [PATCH v4] " Esina Ekaterina
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2023-01-11 18:28 UTC (permalink / raw)
To: Esina Ekaterina
Cc: lvc-project, netdev, linux-kernel, Eric Dumazet, Paolo Abeni,
linuxppc-dev, David S . Miller, Zhao Qiang
On Wed, 11 Jan 2023 12:05:03 +0300 Esina Ekaterina wrote:
> Subject: [PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
net: wan: prevent null-deref on error path for non-tdm case
> 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.
I did the indentation to make the content stand out in the email,
there should be no indentation in the actual msg, sorry.
> --- a/drivers/net/wan/fsl_ucc_hdlc.c
> +++ b/drivers/net/wan/fsl_ucc_hdlc.c
> @@ -1243,9 +1243,11 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
> free_dev:
> free_netdev(dev);
> undo_uhdlc_init:
> - iounmap(utdm->siram);
> + if (utdm != NULL)
and here just:
if (utdm)
comparing to NULL or zero is less idiomatic in kernel C.
> + iounmap(utdm->siram);
> unmap_si_regs:
> - iounmap(utdm->si_regs);
> + if (utdm != NULL)
> + iounmap(utdm->si_regs);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
2023-01-11 18:28 ` Jakub Kicinski
@ 2023-01-11 19:55 ` Esina Ekaterina
2023-01-11 20:10 ` Jakub Kicinski
2023-01-12 7:09 ` Leon Romanovsky
0 siblings, 2 replies; 7+ messages in thread
From: Esina Ekaterina @ 2023-01-11 19:55 UTC (permalink / raw)
To: Zhao Qiang
Cc: lvc-project, netdev, linux-kernel, Eric Dumazet, Esina Ekaterina,
Jakub Kicinski, Paolo Abeni, linuxppc-dev, David S . Miller
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 Astra Linux on behalf of Linux Verification Center
(linuxtesting.org) with SVACE.
Signed-off-by: Esina Ekaterina <eesina@astralinux.ru>
---
v4: Fix style
v3: Remove braces
v2: Add check for NULL for unmap_si_regs
---
drivers/net/wan/fsl_ucc_hdlc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 22edea6ca4b8..1c53b5546927 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1243,9 +1243,11 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
free_dev:
free_netdev(dev);
undo_uhdlc_init:
- iounmap(utdm->siram);
+ if (utdm)
+ iounmap(utdm->siram);
unmap_si_regs:
- iounmap(utdm->si_regs);
+ if (utdm)
+ iounmap(utdm->si_regs);
free_utdm:
if (uhdlc_priv->tsa)
kfree(utdm);
--
2.39.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
2023-01-11 19:55 ` [PATCH v4] " Esina Ekaterina
@ 2023-01-11 20:10 ` Jakub Kicinski
2023-01-12 7:09 ` Leon Romanovsky
1 sibling, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2023-01-11 20:10 UTC (permalink / raw)
To: Esina Ekaterina
Cc: lvc-project, netdev, linux-kernel, Eric Dumazet, Paolo Abeni,
linuxppc-dev, David S . Miller, Zhao Qiang
On Wed, 11 Jan 2023 22:55:33 +0300 Esina Ekaterina wrote:
> Signed-off-by: Esina Ekaterina <eesina@astralinux.ru>
> ---
This --- is still indented.
On top of that please tag the patch for the tree to which networking
maintainers apply fixes (by specifying [PATCH net v5] instead just
[PATCH v5] in the subject).
And add a Fixes tag. If the bug dates all the way back to the start of
the git era add:
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
otherwise use the commit which added the buggy code.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
2023-01-11 19:55 ` [PATCH v4] " Esina Ekaterina
2023-01-11 20:10 ` Jakub Kicinski
@ 2023-01-12 7:09 ` Leon Romanovsky
1 sibling, 0 replies; 7+ messages in thread
From: Leon Romanovsky @ 2023-01-12 7:09 UTC (permalink / raw)
To: Esina Ekaterina
Cc: lvc-project, netdev, linux-kernel, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linuxppc-dev, David S . Miller, Zhao Qiang
On Wed, Jan 11, 2023 at 10:55:33PM +0300, Esina Ekaterina 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 Astra Linux on behalf of Linux Verification Center
> (linuxtesting.org) with SVACE.
>
> Signed-off-by: Esina Ekaterina <eesina@astralinux.ru>
> ---
> v4: Fix style
> v3: Remove braces
> v2: Add check for NULL for unmap_si_regs
> ---
> drivers/net/wan/fsl_ucc_hdlc.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
In addition to what Jakub said, please don't send patches as reply-to.
Please sent them as new threads.
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-01-12 7:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-10 11:47 [PATCH v2] net: wan: Add checks for NULL. 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 Esina Ekaterina
2023-01-11 4:44 ` Jakub Kicinski
2023-01-11 9:05 ` [PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs Esina Ekaterina
2023-01-11 18:28 ` Jakub Kicinski
2023-01-11 19:55 ` [PATCH v4] " Esina Ekaterina
2023-01-11 20:10 ` Jakub Kicinski
2023-01-12 7:09 ` Leon Romanovsky
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).