Skip to contentSkip to conversation

coda/imx-vdoa: Check for platform_get_resource() error

PATCH In review Fabio Estevam 2 participants 2 messages Aug 17, 2017 – Aug 18, 2017

Subsystems (2)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 coda/imx-vdoa: Check for platform_get_resource() error

From: Fabio Estevam <[email protected]>

platform_get_resource() may fail and in this case a NULL dereference will occur.

Prevent this from happening by returning an error on platform_get_resource() failure.

Fixes b0444f18e0b18abce ("[media] coda: add i.MX6 VDOA driver")
---
 drivers/media/platform/coda/imx-vdoa.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/platform/coda/imx-vdoa.c +2 -0
index df9b716..8eb3e0c 100644
@@ -314,6 +314,8 @@ static int vdoa_probe(struct platform_device *pdev)
 		return PTR_ERR(vdoa->regs);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!res)
+		return -EINVAL;
 	vdoa->irq = devm_request_threaded_irq(&pdev->dev, res->start, NULL,
 					vdoa_irq_handler, IRQF_ONESHOT,
 					"vdoa", vdoa);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw

Hi Fabio,

Quoted 21 lines · Fabio Estevam
Quoted 1 line

From: Fabio Estevam <[email protected]>

platform_get_resource() may fail and in this case a NULL dereference will occur.

Prevent this from happening by returning an error on platform_get_resource() failure.

Fixes b0444f18e0b18abce ("[media] coda: add i.MX6 VDOA driver")
Quoted 1 line

---
 drivers/media/platform/coda/imx-vdoa.c | 2 ++

 1 file changed, 2 insertions(+)
drivers/media/platform/coda/imx-vdoa.c +0 -0
index df9b716..8eb3e0c 100644
@@ -314,6 +314,8 @@ static int vdoa_probe(struct platform_device *pdev)
 >  		return PTR_ERR(vdoa->regs);

Quoted 6 lines
Quoted 6 lines

  res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);

drivers/media/platform/coda/imx-vdoa.c +2 -0
+	if (!res)
+		return -EINVAL;

  vdoa->irq = devm_request_threaded_irq(&pdev->dev, res->start, NULL, vdoa_irq_handler, IRQF_ONESHOT, "vdoa", vdoa);

Thank you for the fix! I think it would be better to replace platform_get_resource with platform_get_irq. Either way,

regards
Philipp