Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1467245 > unrolled thread

[PATCH 1/1] virtio-gpu: avoid possible NULL pointer dereference

Started byHeinrich Schuchardt <xypron.glpk@gmx.de>
First post2016-08-21 23:10 +0200
Last post2016-08-21 23:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] virtio-gpu: avoid possible NULL pointer dereference Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-08-21 23:10 +0200

#1467245 — [PATCH 1/1] virtio-gpu: avoid possible NULL pointer dereference

FromHeinrich Schuchardt <xypron.glpk@gmx.de>
Date2016-08-21 23:10 +0200
Subject[PATCH 1/1] virtio-gpu: avoid possible NULL pointer dereference
Message-ID<s8Iad-5xs-7@gated-at.bofh.it>
If output is NULL it is not permissable to dereference it.
So we should leave the respective function in this case.

The inconsistency was indicated by cppcheck.
No actual NULL pointer dereference was observed.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 925ca25..ba28c0f 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -76,7 +76,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 		output = drm_crtc_to_virtio_gpu_output(plane->state->crtc);
 	if (old_state->crtc)
 		output = drm_crtc_to_virtio_gpu_output(old_state->crtc);
-	WARN_ON(!output);
+	if (WARN_ON(!output))
+		return;
 
 	if (plane->state->fb) {
 		vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
@@ -129,7 +130,8 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane,
 		output = drm_crtc_to_virtio_gpu_output(plane->state->crtc);
 	if (old_state->crtc)
 		output = drm_crtc_to_virtio_gpu_output(old_state->crtc);
-	WARN_ON(!output);
+	if (WARN_ON(!output))
+		return;
 
 	if (plane->state->fb) {
 		vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
-- 
2.1.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web