diff mbox

[media] mx2_emmaprp: Check for platform_get_irq() error

Message ID 1503004325-23655-1-git-send-email-festevam@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fabio Estevam Aug. 17, 2017, 9:12 p.m. UTC
From: Fabio Estevam <fabio.estevam@nxp.com>

platform_get_irq() may fail, so we should better check its return
value and propagate it in the case of error.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/media/platform/mx2_emmaprp.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Philipp Zabel Aug. 18, 2017, 7:46 a.m. UTC | #1
Hi Fabio,

On Thu, 2017-08-17 at 18:12 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
> 
> platform_get_irq() may fail, so we should better check its return
> value and propagate it in the case of error.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  drivers/media/platform/mx2_emmaprp.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/mx2_emmaprp.c
> b/drivers/media/platform/mx2_emmaprp.c
> index 03e47e0..f90eaa0 100644
> --- a/drivers/media/platform/mx2_emmaprp.c
> +++ b/drivers/media/platform/mx2_emmaprp.c
> @@ -942,6 +942,8 @@ static int emmaprp_probe(struct platform_device
> *pdev)
>  	platform_set_drvdata(pdev, pcdev);
>  
>  	irq = platform_get_irq(pdev, 0);
> +	if (irq < 0)
> +		return irq;
>  	ret = devm_request_irq(&pdev->dev, irq, emmaprp_irq, 0,
>  			       dev_name(&pdev->dev), pcdev);
>  	if (ret)

For IORESOURCE_MEM + devm_ioremap_resource pairs this seems to be a
pattern in the kernel, though.
Does devm_request_irq reliably return an error when irq is negative? If
so, this check would be redundant.

regards
Philipp
diff mbox

Patch

diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index 03e47e0..f90eaa0 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -942,6 +942,8 @@  static int emmaprp_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, pcdev);
 
 	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
 	ret = devm_request_irq(&pdev->dev, irq, emmaprp_irq, 0,
 			       dev_name(&pdev->dev), pcdev);
 	if (ret)