OSDN Git Service

net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs
authorEsina Ekaterina <eesina@astralinux.ru>
Thu, 12 Jan 2023 07:47:03 +0000 (10:47 +0300)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Jan 2023 05:34:31 +0000 (21:34 -0800)
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.

Fixes: 8d68100ab4ad ("soc/fsl/qe: fix err handling of ucc_of_parse_tdm")
Signed-off-by: Esina Ekaterina <eesina@astralinux.ru>
Link: https://lore.kernel.org/r/20230112074703.13558-1-eesina@astralinux.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/wan/fsl_ucc_hdlc.c

index 22edea6..1c53b55 100644 (file)
@@ -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);