Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4273602ybc; Fri, 15 Nov 2019 01:50:27 -0800 (PST) X-Google-Smtp-Source: APXvYqww+HO5XmcTppZ7/SIcitAGX/l0JnGBA+lF8TtofIM0GR2w2/nSrMQPgQKPW5wN8L4kqIL2 X-Received: by 2002:a17:906:fad1:: with SMTP id lu17mr6961063ejb.24.1573811427316; Fri, 15 Nov 2019 01:50:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573811427; cv=none; d=google.com; s=arc-20160816; b=dE5IMEP+5H2K06mCU99ZiBtGTVak6oagbBkjy9GyKJRfKQDIKUq/pbNnI8GgziAM/I gAwcdWkuSXWWjZdxtyHxxfPgAWiAxUJXSlyQwBfVrRCnRw+fugEQHHddQNANGwpgp5yb 5x+3pKpr+A7cCROYeChZF5WWVcmZ762UUgZZ8zxXXxDqQeLZgOWUg9KsJ1gceEN5tpiA +35zYzeIAEoWuvGipwfOF+4D/KNJKojgB+BRDGXbu0chadKOKTgR1qjaCZTpWQ5ykSTA A/rXs3FxpNfG0w59n9i5xp2soDFNe07JtLNGbvzBLakVn9T6CrM56cxHFumLV+0TEqcZ xkvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=IOmaDykV4LidaAYHGHT0JX/ZdLCYiOK8rRlPSqracVA=; b=S8yokCr4LMq4jqm0+lqeRyBelg1c8+6Yh8mc0dkHrlX4PewYYlamkc4/aSUaj06gaD /an+DA9HOUz7dg0sfeCEPKLT+EQrl/I36cOKWNHzD2/OjIb93fufvxhRVqnrlB+vv0PQ W7vFdgZSIlUFXG1aboLi2vDqqzqII/k2zkLOwPQC7PBLWri39P7FmD7fdSoEelgXXiDV 9TQnNDn75BkVX04MbTPnXA2tUFF5SIIB8DtcSpR3ecscnoLLj++Fn5BrcWQnc3PE303X ctvQSb9iATz7+TFuba89QuVV7IHaZbdOszQiEdj3BBitBt1+fftcBLWPijqoeLwgH8SX 2iUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20si5052953ejm.348.2019.11.15.01.50.01; Fri, 15 Nov 2019 01:50:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbfKOJr7 (ORCPT + 99 others); Fri, 15 Nov 2019 04:47:59 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:41250 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbfKOJr7 (ORCPT ); Fri, 15 Nov 2019 04:47:59 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iVYCo-0002Zt-Iq; Fri, 15 Nov 2019 09:47:54 +0000 From: Colin King To: Rex Zhu , Evan Quan , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Zhou , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] drm/amdgpu/powerplay: fix dereference before null check of pointer hwmgr Date: Fri, 15 Nov 2019 09:47:54 +0000 Message-Id: <20191115094754.40920-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The assignment of adev dereferences pointer hwmgr before hwmgr is null checked, hence there is a potential null pointer deference issue. Fix this by assigning adev after the null check. Addresses-Coverity: ("Dereference before null check") Fixes: 0896d2f7ba4d ("drm/amdgpu/powerplay: properly set PP_GFXOFF_MASK") Signed-off-by: Colin Ian King --- drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c index 443625c83ec9..d2909c91d65b 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c @@ -81,7 +81,7 @@ static void hwmgr_init_workload_prority(struct pp_hwmgr *hwmgr) int hwmgr_early_init(struct pp_hwmgr *hwmgr) { - struct amdgpu_device *adev = hwmgr->adev; + struct amdgpu_device *adev; if (!hwmgr) return -EINVAL; @@ -96,6 +96,8 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr) hwmgr_init_workload_prority(hwmgr); hwmgr->gfxoff_state_changed_by_workload = false; + adev = hwmgr->adev; + switch (hwmgr->chip_family) { case AMDGPU_FAMILY_CI: adev->pm.pp_feature &= ~PP_GFXOFF_MASK; -- 2.20.1