__drm_fb_helper_initial_config_and_unlock() question
Subsystems (2)
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.
Quoted 10 lines · Bart Van Assche
The comment above
__drm_fb_helper_initial_config_and_unlock()says "Dropsfb_helper->lockbefore returning". However, there is an error path in that function that does not dropfb_helper->lock:info =
drm_fb_helper_alloc_info(fb_helper); if (IS_ERR(info))
returnPTR_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.
drivers/gpu/drm/drm_fb_helper.c +3 -1
@@ -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 ) {