Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio-gpu: avoid possible NULL pointer dereference

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>
Message-id: 1471813566-5324-1-git-send-email-xypron.glpk@gmx.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

authored by

Heinrich Schuchardt and committed by
Gerd Hoffmann
b28c69dd 4532b241

+4 -2
+4 -2
drivers/gpu/drm/virtio/virtgpu_plane.c
··· 76 76 output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); 77 77 if (old_state->crtc) 78 78 output = drm_crtc_to_virtio_gpu_output(old_state->crtc); 79 - WARN_ON(!output); 79 + if (WARN_ON(!output)) 80 + return; 80 81 81 82 if (plane->state->fb) { 82 83 vgfb = to_virtio_gpu_framebuffer(plane->state->fb); ··· 130 129 output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); 131 130 if (old_state->crtc) 132 131 output = drm_crtc_to_virtio_gpu_output(old_state->crtc); 133 - WARN_ON(!output); 132 + if (WARN_ON(!output)) 133 + return; 134 134 135 135 if (plane->state->fb) { 136 136 vgfb = to_virtio_gpu_framebuffer(plane->state->fb);