Skip to contentSkip to conversation

__drm_fb_helper_initial_config_and_unlock() question

DISCUSSION Bart Van Assche 1 participant 2 messages Mar 3

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

Hi,

The comment above __drm_fb_helper_initial_config_and_unlock() says "Drops fb_helper->lock before returning". However, there is an error path in that function that does not drop fb_helper->lock:

        info = drm_fb_helper_alloc_info(fb_helper);
        if (IS_ERR(info))
                return PTR_ERR(info);

Is the code correct or is the comment correct? I don't think that both can be correct.

Thanks,

Bart.

#1 lore raw
Quoted 10 lines · Bart Van Assche

The comment above __drm_fb_helper_initial_config_and_unlock() says "Drops fb_helper->lock before returning". However, there is an error path in that function that does not drop fb_helper->lock:

        info = drm_fb_helper_alloc_info(fb_helper); if (IS_ERR(info))
                return PTR_ERR(info);

Is the code correct or is the comment correct? I don't think that both can be correct.

(+Thomas)

Thomas,

Does this untested patch make sense to you?

Thanks,

Bart.

drm: Fix a locking bug in an error path

Make sure that __drm_fb_helper_initial_config_and_unlock() unlocks fb_helper->lock. This has been detected by the Clang thread-safety analyzer.

Fixes 63c971af4036 ("drm/fb-helper: Allocate and release fb_info in single place")
drivers/gpu/drm/drm_fb_helper.c +3 -1
index 05803169bed5..16bfbfb0af16 100644
@@ -1641,8 +1641,10 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)
        drm_client_modeset_probe(&fb_helper->client, width, height);
 
        info = drm_fb_helper_alloc_info(fb_helper);
-       if (IS_ERR(info))
+       if (IS_ERR(info)) {
+               mutex_unlock(&fb_helper->lock);
                return PTR_ERR(info);
+       }
 
        ret = drm_fb_helper_single_fb_probe(fb_helper);
        if (ret < 0) {