diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-11-19 04:44:58 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-11-20 00:40:56 -0500 |
commit | 8c5eaca012f963fa9724665f8a0eca19e3cb7d2a (patch) | |
tree | 0cb9fff757da368a457aba0580e9027048868313 /drivers/gpu/drm/drm_fb_helper.c | |
parent | e655d122a71332d0d26b5c0909eb395da31af0c0 (diff) |
drm/fb_helper: Fix potential NULL pointer dereference
kcalloc returns NULL on failure. Hence check for the return value
and exit on error to avoid NULL pointer dereference.
Fixes the following smatch errors:
drivers/gpu/drm/drm_fb_helper.c:1271 drm_setup_crtcs() error:
potential null dereference 'modes'. (kcalloc returns null)
drivers/gpu/drm/drm_fb_helper.c:1272 drm_setup_crtcs() error:
potential null dereference 'crtcs'. (kcalloc returns null)
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_fb_helper.c')
-rw-r--r-- | drivers/gpu/drm/drm_fb_helper.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 8c2de020e8eb..2c44af691e98 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
@@ -1251,6 +1251,11 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper) | |||
1251 | sizeof(struct drm_display_mode *), GFP_KERNEL); | 1251 | sizeof(struct drm_display_mode *), GFP_KERNEL); |
1252 | enabled = kcalloc(dev->mode_config.num_connector, | 1252 | enabled = kcalloc(dev->mode_config.num_connector, |
1253 | sizeof(bool), GFP_KERNEL); | 1253 | sizeof(bool), GFP_KERNEL); |
1254 | if (!crtcs || !modes || !enabled) { | ||
1255 | DRM_ERROR("Memory allocation failed\n"); | ||
1256 | goto out; | ||
1257 | } | ||
1258 | |||
1254 | 1259 | ||
1255 | drm_enable_connectors(fb_helper, enabled); | 1260 | drm_enable_connectors(fb_helper, enabled); |
1256 | 1261 | ||
@@ -1289,6 +1294,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper) | |||
1289 | } | 1294 | } |
1290 | } | 1295 | } |
1291 | 1296 | ||
1297 | out: | ||
1292 | kfree(crtcs); | 1298 | kfree(crtcs); |
1293 | kfree(modes); | 1299 | kfree(modes); |
1294 | kfree(enabled); | 1300 | kfree(enabled); |