summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo A. R. Silva <garsilva@embeddedor.com>2017-12-05 20:46:28 +0300
committerDaniel Vetter <daniel.vetter@ffwll.ch>2017-12-06 23:45:28 +0300
commit89f3f35620c7f244880485de11079cb4d98ed604 (patch)
tree266b625bfd7d9371a0022c944b3800e7dba5f783
parentec17f0341d6a2c8b8a036999e9fd735a1a6888f4 (diff)
downloadlinux-89f3f35620c7f244880485de11079cb4d98ed604.tar.xz
drm/fb-helper: Fix potential NULL pointer dereference
fb_helper is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after fb_helper has been null checked. This issue was detected with the help of Coccinelle. Fixes: c777990fb45b ("drm/fb-helper: Handle function NULL argument") Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20171205174628.GA31189@embeddedor.com
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 6654f2f87775..04a3a5ce370a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -178,7 +178,7 @@ EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
*/
int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
{
- struct drm_device *dev = fb_helper->dev;
+ struct drm_device *dev;
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter;
int i, ret = 0;
@@ -186,6 +186,8 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation || !fb_helper)
return 0;
+ dev = fb_helper->dev;
+
mutex_lock(&fb_helper->lock);
drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) {