[PATCH v3] net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs

Jakub Kicinski kuba at kernel.org
Thu Jan 12 05:28:48 AEDT 2023


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


More information about the Linuxppc-dev mailing list