public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] coda/imx-vdoa: Check for platform_get_resource() error
@ 2017-08-17  0:14 Fabio Estevam
  2017-08-18  7:43 ` Philipp Zabel
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2017-08-17  0:14 UTC (permalink / raw)
  To: p.zabel; +Cc: mchehab, hansverk, linux-media, Fabio Estevam

From: Fabio Estevam <fabio.estevam@nxp.com>

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")
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/media/platform/coda/imx-vdoa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/coda/imx-vdoa.c b/drivers/media/platform/coda/imx-vdoa.c
index df9b716..8eb3e0c 100644
--- a/drivers/media/platform/coda/imx-vdoa.c
+++ b/drivers/media/platform/coda/imx-vdoa.c
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [media] coda/imx-vdoa: Check for platform_get_resource() error
  2017-08-17  0:14 [PATCH] [media] coda/imx-vdoa: Check for platform_get_resource() error Fabio Estevam
@ 2017-08-18  7:43 ` Philipp Zabel
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Zabel @ 2017-08-18  7:43 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: mchehab, hansverk, linux-media, Fabio Estevam

Hi Fabio,

On Wed, 2017-08-16 at 21:14 -0300, Fabio Estevam wrote:
> > From: Fabio Estevam <fabio.estevam@nxp.com>
> 
> 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")
> > Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  drivers/media/platform/coda/imx-vdoa.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/coda/imx-vdoa.c b/drivers/media/platform/coda/imx-vdoa.c
> index df9b716..8eb3e0c 100644
> --- a/drivers/media/platform/coda/imx-vdoa.c
> +++ b/drivers/media/platform/coda/imx-vdoa.c
> @@ -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);

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

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-18  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17  0:14 [PATCH] [media] coda/imx-vdoa: Check for platform_get_resource() error Fabio Estevam
2017-08-18  7:43 ` Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox