fbdev: mxc_hdmi: hotplug: lock fb_info before modification #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When an HDMI hotplug interrupt occurs, it schedules hotplug_worker(), which indirectly makes one or more calls to fb_videomode_to_var() that modify the fb_info struct associated with the HDMI connection. These can occur concurrently with the handling of an FBIOPUT_VSCREENINFO ioctl which also reads, modifies, and writes the same fields of fb_info, leading to race conditions.
This patch holds the fb_info lock in mxc_hdmi_cable_connected() while calling mxc_hdmi_set_mode(), eliminating those race conditions.
All of the hogplug handler's calls to fb_videomode_to_var() happen either directly or indirectly from mxc_hdmi_set_mode(), which is called from only one place, in mxc_hdmi_cable_connected(). That seems like the most convenient, least invasive, easiest to get right place to take and release the fb_info lock.