diff options
author | Joe Moriarty <joe.moriarty@oracle.com> | 2018-02-20 14:11:56 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2018-03-06 02:14:16 -0500 |
commit | 4ffb8deeed58b75dd1a23580845233b6ce0dca6c (patch) | |
tree | 71cd0f060ae9f5643426fe5b17da5f360df53583 | |
parent | 81af63a4af82e739aaa391d1fbb97e02c58ea6a1 (diff) |
drm: NULL pointer dereference [null-pointer-deref] (CWE 476) problem
The Parfait (version 2.1.0) static code analysis tool found the
following NULL pointer derefernce problem.
- drivers/gpu/drm/drm_vblank.c
Null pointer checks were added to return values from calls to
drm_crtc_from_index(). There is a possibility, however minute, that
crtc->index may not be found when trying to find the struct crtc
from it's assigned index given in drm_crtc_init_with_planes().
3 return checks for NULL where added with a call to
WARN_ON(!crtc).
Signed-off-by: Joe Moriarty <joe.moriarty@oracle.com>
Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20180220191157.100960-2-joe.moriarty@oracle.com
-rw-r--r-- | drivers/gpu/drm/drm_vblank.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 32d9bcf5be7f..03b431eb47ae 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c | |||
@@ -120,6 +120,9 @@ static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe) | |||
120 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | 120 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
121 | struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); | 121 | struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); |
122 | 122 | ||
123 | if (WARN_ON(!crtc)) | ||
124 | return 0; | ||
125 | |||
123 | if (crtc->funcs->get_vblank_counter) | 126 | if (crtc->funcs->get_vblank_counter) |
124 | return crtc->funcs->get_vblank_counter(crtc); | 127 | return crtc->funcs->get_vblank_counter(crtc); |
125 | } | 128 | } |
@@ -318,6 +321,9 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe) | |||
318 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | 321 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
319 | struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); | 322 | struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); |
320 | 323 | ||
324 | if (WARN_ON(!crtc)) | ||
325 | return; | ||
326 | |||
321 | if (crtc->funcs->disable_vblank) { | 327 | if (crtc->funcs->disable_vblank) { |
322 | crtc->funcs->disable_vblank(crtc); | 328 | crtc->funcs->disable_vblank(crtc); |
323 | return; | 329 | return; |
@@ -918,6 +924,9 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe) | |||
918 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | 924 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
919 | struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); | 925 | struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); |
920 | 926 | ||
927 | if (WARN_ON(!crtc)) | ||
928 | return 0; | ||
929 | |||
921 | if (crtc->funcs->enable_vblank) | 930 | if (crtc->funcs->enable_vblank) |
922 | return crtc->funcs->enable_vblank(crtc); | 931 | return crtc->funcs->enable_vblank(crtc); |
923 | } | 932 | } |