Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753675AbdCWMWj (ORCPT ); Thu, 23 Mar 2017 08:22:39 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:32953 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228AbdCWMWi (ORCPT ); Thu, 23 Mar 2017 08:22:38 -0400 From: Colin King To: Zhenyu Wang , Zhi Wang , Daniel Vetter , Jani Nikula , David Airlie , intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer Date: Thu, 23 Mar 2017 12:22:30 +0000 Message-Id: <20170323122230.19064-1-colin.king@canonical.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1231 Lines: 35 From: Colin Ian King 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 --- 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