Message ID | 20250313-mxsfb_probe-fix-rollback-on-error-v2-1-38374088e8c7@bootlin.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2] drm/mxsfb: fix missing rollback on failure in mxsfb_probe() | expand |
Hi Am 13.03.25 um 16:21 schrieb Luca Ceresoli: > When aperture_remove_all_conflicting_devices() fails, the current code > returns without going through the rollback actions at the end of the > function, thus the actions done by drm_dev_alloc() and mxsfb_load() are not > undone. > > Fix by moving this call at the very beginning of the probe function, so > that no rollback is needed if it fails. Conflicting drivers need to be > kicked out before setting up DRM anyway. > > Fixes: c8e7b185d45b ("drm/mxsfb: Remove generic DRM drivers in probe function") > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> The patchdiff is somewhat non-intuitive, but looks correct. Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Thanks for the fix. Best regards Thomas > --- > The offending commit is not yet merged into master, and even less in a > released kernel, so this does not need to go through stable. > > Changes in v2: > - move this call at the beginning instead of adding a goto > --- > drivers/gpu/drm/mxsfb/mxsfb_drv.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c > index c183b1112bc4e9fe4f3b048a2b6e4c98d1d47cb3..ee64053d381448360140c419fed1dc4fe9f7c68e 100644 > --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c > +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c > @@ -352,14 +352,6 @@ static int mxsfb_probe(struct platform_device *pdev) > struct drm_device *drm; > int ret; > > - drm = drm_dev_alloc(&mxsfb_driver, &pdev->dev); > - if (IS_ERR(drm)) > - return PTR_ERR(drm); > - > - ret = mxsfb_load(drm, device_get_match_data(&pdev->dev)); > - if (ret) > - goto err_free; > - > /* > * Remove early framebuffers (ie. simplefb). The framebuffer can be > * located anywhere in RAM > @@ -369,6 +361,14 @@ static int mxsfb_probe(struct platform_device *pdev) > return dev_err_probe(&pdev->dev, ret, > "can't kick out existing framebuffers\n"); > > + drm = drm_dev_alloc(&mxsfb_driver, &pdev->dev); > + if (IS_ERR(drm)) > + return PTR_ERR(drm); > + > + ret = mxsfb_load(drm, device_get_match_data(&pdev->dev)); > + if (ret) > + goto err_free; > + > ret = drm_dev_register(drm, 0); > if (ret) > goto err_unload; > > --- > base-commit: f9f087d946266bc5da7c3a17bd8fd9d01969e3cf > change-id: 20250313-mxsfb_probe-fix-rollback-on-error-3074b9080f34 > > Best regards,
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index c183b1112bc4e9fe4f3b048a2b6e4c98d1d47cb3..ee64053d381448360140c419fed1dc4fe9f7c68e 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -352,14 +352,6 @@ static int mxsfb_probe(struct platform_device *pdev) struct drm_device *drm; int ret; - drm = drm_dev_alloc(&mxsfb_driver, &pdev->dev); - if (IS_ERR(drm)) - return PTR_ERR(drm); - - ret = mxsfb_load(drm, device_get_match_data(&pdev->dev)); - if (ret) - goto err_free; - /* * Remove early framebuffers (ie. simplefb). The framebuffer can be * located anywhere in RAM @@ -369,6 +361,14 @@ static int mxsfb_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, ret, "can't kick out existing framebuffers\n"); + drm = drm_dev_alloc(&mxsfb_driver, &pdev->dev); + if (IS_ERR(drm)) + return PTR_ERR(drm); + + ret = mxsfb_load(drm, device_get_match_data(&pdev->dev)); + if (ret) + goto err_free; + ret = drm_dev_register(drm, 0); if (ret) goto err_unload;
When aperture_remove_all_conflicting_devices() fails, the current code returns without going through the rollback actions at the end of the function, thus the actions done by drm_dev_alloc() and mxsfb_load() are not undone. Fix by moving this call at the very beginning of the probe function, so that no rollback is needed if it fails. Conflicting drivers need to be kicked out before setting up DRM anyway. Fixes: c8e7b185d45b ("drm/mxsfb: Remove generic DRM drivers in probe function") Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> --- The offending commit is not yet merged into master, and even less in a released kernel, so this does not need to go through stable. Changes in v2: - move this call at the beginning instead of adding a goto --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- base-commit: f9f087d946266bc5da7c3a17bd8fd9d01969e3cf change-id: 20250313-mxsfb_probe-fix-rollback-on-error-3074b9080f34 Best regards,