lkml.org 
[lkml]   [2023]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
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);

\
 
 \ /
  Last update: 2023-03-26 23:36    [W:0.048 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site