Skip to contentSkip to conversation

s5p-jpeg: hangle error condition in s5p_jpeg_probe

PATCH In review Baskov Evgeiny 3 participants 4 messages Nov 13, 2020 – Nov 14, 2020 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s5p-jpeg: hangle error condition in s5p_jpeg_probe

If an error happens in jpeg_get_drv_data(), i.e. match fails, jpeg->variant field is NULL, so we cannot access it.

Consider device probe failed if jpeg->variant is NULL.

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

---
 drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/platform/s5p-jpeg/jpeg-core.c +2 -0
index 9b22dd8e34f4..026111505f5a 100644
@@ -2862,6 +2862,8 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	jpeg->variant = jpeg_get_drv_data(&pdev->dev);
+	if (!jpeg->variant)
+		return -ENODEV;
 
 	mutex_init(&jpeg->lock);
 	spin_lock_init(&jpeg->slock);
Signature · 7 lines
2.29.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 1/1
#1 lore raw

W dniu 13.11.2020 o 17:06, Baskov Evgeiny pisze:

Quoted 26 lines

If an error happens in jpeg_get_drv_data(), i.e. match fails, jpeg->variant field is NULL, so we cannot access it.

Consider device probe failed if jpeg->variant is NULL.

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

---
  drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/media/platform/s5p-jpeg/jpeg-core.c +2 -0
index 9b22dd8e34f4..026111505f5a 100644
@@ -2862,6 +2862,8 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
  		return -ENOMEM;
 
  	jpeg->variant = jpeg_get_drv_data(&pdev->dev);
+	if (!jpeg->variant)
+		return -ENODEV;
 
  	mutex_init(&jpeg->lock);
  	spin_lock_init(&jpeg->slock);
Acked-by on v1 1/1
#2 lore raw
In reply to Baskov Evgeiny

Hi Evgeiny,

Thank you for the patch.

There is a typo in the subject: s/hangle/handle/

Otherwise:

Quoted 4 lines · Baskov Evgeiny

If an error happens in jpeg_get_drv_data(), i.e. match fails, jpeg->variant field is NULL, so we cannot access it.

Consider device probe failed if jpeg->variant is NULL.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#3 lore raw
Quoted 1 line · Jacek Anaszewski

There is a typo in the subject: s/hangle/handle/

Thanks for pointing out, sorry for that.

Apparently, there is also a typo in my name -> s/Evgeiny/Evgeniy/

--
Respectfully,
Baskov Evgeniy