media: s5p-mfc: Add checking to s5p_mfc_probe().
authorNadezda Lutovinova <lutovinova@ispras.ru>
Wed, 11 Aug 2021 13:32:28 +0000 (15:32 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 30 Sep 2021 08:07:54 +0000 (10:07 +0200)
If of_device_get_match_data() return NULL,
then null pointer dereference occurs in  s5p_mfc_init_pm().
The patch adds checking if dev->variant is NULL.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/s5p-mfc/s5p_mfc.c

index 293af8e..fc85e4e 100644 (file)
@@ -1288,6 +1288,10 @@ static int s5p_mfc_probe(struct platform_device *pdev)
        }
 
        dev->variant = of_device_get_match_data(&pdev->dev);
+       if (!dev->variant) {
+               dev_err(&pdev->dev, "Failed to get device MFC hardware variant information\n");
+               return -ENOENT;
+       }
 
        dev->regs_base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(dev->regs_base))