All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-23 12:22 ` Colin King
  0 siblings, 0 replies; 13+ messages in thread
From: Colin King @ 2017-03-23 12:22 UTC (permalink / raw)
  To: Zhenyu Wang, Zhi Wang, Daniel Vetter, Jani Nikula, David Airlie,
	intel-gvt-dev, intel-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

info is being checked to see if it is a null pointer, however, vpgu is
dereferencing info before this check, leading to a potential null
pointer dereference.  If info is null, then the error message being
printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
use a null vpgu as the macro has a sanity check to see if vpgu is null,
so this is OK.

Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")

Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 1ea3eb270de8..f8619a772c44 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
 
 static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
 {
-	struct intel_vgpu *vgpu = info->vgpu;
-
 	if (!info) {
+		struct intel_vgpu *vgpu = NULL;
+
 		gvt_vgpu_err("kvmgt_guest_info invalid\n");
 		return false;
 	}
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-03-24  3:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-23 12:22 [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer Colin King
2017-03-23 12:22 ` Colin King
2017-03-23 12:39 ` Chris Wilson
2017-03-23 12:39   ` Chris Wilson
2017-03-23 12:39   ` Chris Wilson
2017-03-23 14:11   ` Joonas Lahtinen
2017-03-24  3:06     ` Zhenyu Wang
2017-03-23 13:16 ` ✗ Fi.CI.BAT: warning for " Patchwork
2017-03-23 13:43 ` [PATCH] " Frans Klaver
2017-03-23 13:43   ` Frans Klaver
2017-03-24  3:38   ` Zhenyu Wang
2017-03-24  3:38     ` Zhenyu Wang
2017-03-24  3:38     ` Zhenyu Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.