Skip to contentSkip to conversation

media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe()

PATCH New Tuo Li 1 participant 1 message Aug 5, 2021 Media (V4L/DVB)

lore
Share & tools
lore

Tuo Li

author
#0 lore raw

PATCH 1/1 media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe()

The variable pdev is assigned to dev->plat_dev, and dev->plat_dev is checked in:
if (!dev->plat_dev)

This indicates both dev->plat_dev and pdev can be NULL. If so, the function dev_err() is called to print error infomation.
dev_err(&pdev->dev, "No platform data specified\n");

However, &pdev->dev is an illegal address, and it is dereferenced in dev_err().

To fix this possible null-pointer dereference, replace dev_err() with mfc_err().

---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +1 -1
index eba2b9f040df..c763c0a03140 100644
@@ -1283,7 +1283,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
 	spin_lock_init(&dev->condlock);
 	dev->plat_dev = pdev;
 	if (!dev->plat_dev) {
-		dev_err(&pdev->dev, "No platform data specified\n");
+		mfc_err("No platform data specified\n");
 		return -ENODEV;
 	}
 
Signature · 1 line
2.25.1