Skip to contentSkip to conversation

drm/gma500: clean up modeset on backlight init failure

PATCH In review Myeonghun Pak 2 participants 3 messages May 24 – Sep 15

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/gma500: clean up modeset on backlight init failure

psb_driver_load() initializes KMS polling before it attempts to initialize backlight support. If gma_backlight_init() fails, the function returns directly and skips psb_driver_unload(), leaving drm_kms_helper_poll_fini() uncalled.

Use the existing error path so the partially initialized modeset state is unwound before probe fails.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 1f90b1232773 ("drm/gma500: Refactor backlight support (v2)")
---
 drivers/gpu/drm/gma500/psb_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/gma500/psb_drv.c +1 -1
index 005ab7f535..7218026fe2 100644
@@ -406,7 +406,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 	drm_connector_list_iter_end(&conn_iter);
 
 	if (ret)
-		return ret;
+		goto out_err;
 	psb_intel_opregion_enable_asle(dev);
 
 	return devm_add_action_or_reset(dev->dev, psb_device_release, dev);
Signature · 1 line
2.47.1
maintainer
#1 lore raw
Quoted 8 lines · Myeonghun Pak

psb_driver_load() initializes KMS polling before it attempts to initialize backlight support. If gma_backlight_init() fails, the function returns directly and skips psb_driver_unload(), leaving drm_kms_helper_poll_fini() uncalled.

Use the existing error path so the partially initialized modeset state is unwound before probe fails.

Hi,
Yes the existing code is faulty but calling psb_driver_unload() to unwind the init could call backlight_device_unregister() on an ERR_PTR backlight_device which is guaranteed to fail.

The correct fix would be to convert psb_driver_load() to use devm and/or goto unwind pattern.

-Patrik

Quoted 29 lines

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 1f90b1232773 ("drm/gma500: Refactor backlight support (v2)")
---
 drivers/gpu/drm/gma500/psb_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/gma500/psb_drv.c +1 -2
index 005ab7f535..7218026fe2 100644
@@ -406,7 +406,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
        drm_connector_list_iter_end(&conn_iter);
 
        if (ret)
-               return ret;
+               goto out_err;
        psb_intel_opregion_enable_asle(dev);
 
        return devm_add_action_or_reset(dev->dev, psb_device_release, dev);
--

2.47.1

#2 lore raw

Hi Patrik,

Thanks for the feedback. I'll address this and submit v2.

Thanks,
Myeonghun

2026년 6월 1일 (월) 오전 5:50, Patrik Jakobsson <[email protected]>님이 작성:

Quoted 50 lines · Myeonghun Pak
Quoted 8 lines

psb_driver_load() initializes KMS polling before it attempts to initialize backlight support. If gma_backlight_init() fails, the function returns directly and skips psb_driver_unload(), leaving drm_kms_helper_poll_fini() uncalled.

Use the existing error path so the partially initialized modeset state is unwound before probe fails.

Hi,
Yes the existing code is faulty but calling psb_driver_unload() to unwind the init could call backlight_device_unregister() on an ERR_PTR backlight_device which is guaranteed to fail.

The correct fix would be to convert psb_driver_load() to use devm and/or goto unwind pattern.

-Patrik

Quoted 29 lines

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 1f90b1232773 ("drm/gma500: Refactor backlight support (v2)")
---
 drivers/gpu/drm/gma500/psb_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/gma500/psb_drv.c +1 -2
index 005ab7f535..7218026fe2 100644
@@ -406,7 +406,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
        drm_connector_list_iter_end(&conn_iter);
 
        if (ret)
-               return ret;
+               goto out_err;
        psb_intel_opregion_enable_asle(dev);
 
        return devm_add_action_or_reset(dev->dev, psb_device_release, dev);
--

2.47.1