[PATCH 5.15 120/530] media: cedrus: Set the platform driver data earlier

From: Greg Kroah-Hartman
Date: Mon Oct 24 2022 - 15:41:10 EST


From: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>

commit 708938f8495147fe2e77a9a3e1015d8e6899323e upstream.

The cedrus_hw_resume() crashes with NULL deference on driver probe if
runtime PM is disabled because it uses platform data that hasn't been
set up yet. Fix this by setting the platform data earlier during probe.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 50e761516f2b (media: platform: Add Cedrus VPU decoder driver)
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>
Reviewed-by: Samuel Holland <samuel@xxxxxxxxxxxx>
Acked-by: Paul Kocialkowski <paul.kocialkowski@xxxxxxxxxxx>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/staging/media/sunxi/cedrus/cedrus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -369,6 +369,8 @@ static int cedrus_probe(struct platform_
if (!dev)
return -ENOMEM;

+ platform_set_drvdata(pdev, dev);
+
dev->vfd = cedrus_video_device;
dev->dev = &pdev->dev;
dev->pdev = pdev;
@@ -440,8 +442,6 @@ static int cedrus_probe(struct platform_
goto err_m2m_mc;
}

- platform_set_drvdata(pdev, dev);
-
return 0;

err_m2m_mc: