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

Esina Ekaterina eesina at astralinux.ru
Wed Jan 11 20:05:03 AEDT 2023


  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 at 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



More information about the Linuxppc-dev mailing list