[PATCH 6.4 222/800] drm/imx/lcdc: fix a NULL vs IS_ERR() bug in probe

Greg Kroah-Hartman
2023-07-16T20:03:10Z

From: Dan Carpenter <error27@gmail.com>

[ Upstream commit dae2f7b89a8436351a2982d0d96a8a56accca576 ]

The devm_drm_dev_alloc() function returns error pointers. It never
returns NULL. Fix the check.

Fixes: c87e859cdeb5 ("drm/imx/lcdc: Implement DRM driver for imx25")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/d0a1fc55-3ef6-444e-b3ef-fdc937d8d57a@kili.mountain
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/imx/lcdc/imx-lcdc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/lcdc/imx-lcdc.c b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
index 8e6d457917daf..277ead6a459a4 100644
--- a/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
+++ b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
@@ -400,8 +400,8 @@ static int imx_lcdc_probe(struct platform_device *pdev)

lcdc = devm_drm_dev_alloc(dev, &imx_lcdc_drm_driver,
struct imx_lcdc, drm);
- if (!lcdc)
- return -ENOMEM;
+ if (IS_ERR(lcdc))
+ return PTR_ERR(lcdc);

drm = &lcdc->drm;

--
2.39.2