diff mbox series

media: imx-pxp: fix ERR_PTR dereference in pxp_probe()

Message ID 20240514094458.3463408-1-harshit.m.mogalapalli@oracle.com (mailing list archive)
State New
Headers show
Series media: imx-pxp: fix ERR_PTR dereference in pxp_probe() | expand

Commit Message

Harshit Mogalapalli May 14, 2024, 9:44 a.m. UTC
devm_regmap_init_mmio() can fail, add a check and bail out in case of
error.

Fixes: 4e5bd3fdbeb3 ("media: imx-pxp: convert to regmap")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
 drivers/media/platform/nxp/imx-pxp.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Harshit Mogalapalli May 14, 2024, 9:46 a.m. UTC | #1
Hi,
On 14/05/24 15:14, Harshit Mogalapalli wrote:
> devm_regmap_init_mmio() can fail, add a check and bail out in case of
> error.
> 

Please ignore this patch, I will send a V2.(v1->v2, I have to remove %d 
in error message)

Thanks,
Harshit
> Fixes: 4e5bd3fdbeb3 ("media: imx-pxp: convert to regmap")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
>   drivers/media/platform/nxp/imx-pxp.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
> index e62dc5c1a4ae..58c10156c7a4 100644
> --- a/drivers/media/platform/nxp/imx-pxp.c
> +++ b/drivers/media/platform/nxp/imx-pxp.c
> @@ -1805,6 +1805,9 @@ static int pxp_probe(struct platform_device *pdev)
>   		return PTR_ERR(mmio);
>   	dev->regmap = devm_regmap_init_mmio(&pdev->dev, mmio,
>   					    &pxp_regmap_config);
> +	if (IS_ERR(dev->regmap))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(dev->regmap),
> +				     "Failed to init regmap: %d\n");
>   
>   	irq = platform_get_irq(pdev, 0);
>   	if (irq < 0)
diff mbox series

Patch

diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
index e62dc5c1a4ae..58c10156c7a4 100644
--- a/drivers/media/platform/nxp/imx-pxp.c
+++ b/drivers/media/platform/nxp/imx-pxp.c
@@ -1805,6 +1805,9 @@  static int pxp_probe(struct platform_device *pdev)
 		return PTR_ERR(mmio);
 	dev->regmap = devm_regmap_init_mmio(&pdev->dev, mmio,
 					    &pxp_regmap_config);
+	if (IS_ERR(dev->regmap))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dev->regmap),
+				     "Failed to init regmap: %d\n");
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)