Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp391701ybl; Fri, 30 Aug 2019 01:08:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVQGz8x5USaZlwdcU14mZ+6JrjnLRcvZyZzSgFJl0kECGFWBhSZ+kuLanlmSCwKmRMk6M5 X-Received: by 2002:a63:2807:: with SMTP id o7mr12170302pgo.131.1567152504484; Fri, 30 Aug 2019 01:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567152504; cv=none; d=google.com; s=arc-20160816; b=LE9ghxzwu54MyAc7q+2bjCkCygXluk2DYfd7argTIv941yfadC5xfClG5NN1HwIsKl ZHM0w6WHNXLLlCne7qVqdrY43vD1ySHOc1wKAQWKnmui5HR/qvxsqkInrDAS80PD6QNW MyEiTOuAfpH/34VKasoQ/CPdsmtbBRcEHmG56RWzBqBZSO277dxpHX8FGv6p89KLdWE+ 8Ckw0oT3ogl3cS6vwUOgVv+pNlk2MPkldxFdIML1XDtp7NNoX9RZyJIaXGDlD27TKy/x wT9opiVJuO8UT0xKzc64VvsR1KdPOF0QhADCATU82ZmsnW0JuZsVObtk7U5G3R9b2YxH uytg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=MXRSo7Bfbe6lDlHCJm+CIISENbRdG4l7siPy76JG7SU=; b=iCFIW/xZ5SXn0oQ6WOTOGuSO2FpNiaPcNIByrN8vNYNOCpKKTWR2V7OHI7AbFFk1Hy MBhhJcA30+rjVq9i7MEW0d1ka5TuDVZ37IFIlnbW+vB0TNi+Bvce1AoMGgxhceQ4Zc93 gvqzo70oIG+0rEswzocAXDIjn2XQIEu+wy3SdCGMaQbW7LrTHF7Y+Fh0b70CwcemL2ly ZBRA9QwINN9zjJ1lE/a4b9ydy6jCmkO+0o838HauqrdeB/3hsduG9nKLAfl/HbXsjkOO E6Ph0V1M8hoqtsc57Q/CeSMHIS/g8/+Fc0VuU7rtYWuiyz41v0V52++NvUYqfTpUTBdR 41EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lqWNiLgQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y27si5508693pff.50.2019.08.30.01.08.09; Fri, 30 Aug 2019 01:08:24 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lqWNiLgQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728176AbfH3IHK (ORCPT + 99 others); Fri, 30 Aug 2019 04:07:10 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42138 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbfH3IHK (ORCPT ); Fri, 30 Aug 2019 04:07:10 -0400 Received: by mail-pf1-f195.google.com with SMTP id 26so1766336pfp.9 for ; Fri, 30 Aug 2019 01:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=MXRSo7Bfbe6lDlHCJm+CIISENbRdG4l7siPy76JG7SU=; b=lqWNiLgQRKoeRFx5gu3wvDbkipZoLgcIkAg7cNMOCVqf7X4rfBm+KpoYRqHhu9dw05 /tNQVj7lqrk15NlFAa6ckxFZo20CEvy/CFkDB5dtBf9F4xxsoJwR2VvIfFH4jq7sl35d tvDgUC4x7mgnxniJO4br8Tb1OX9F72mVL1ACp51JPKY4O8T8YB9aXB9hJGVO/ePIDYiW ACA1f8zYp9MSxOSCfabML8xqwIKowg2j0VH74y9gJmQ6yK2Mg4QtMCSkM+pF2lxZ8xzn h53kiOouU7VOeTv2vs6h3jFgxj+fAp/A/qUtxR09wAGpLjtCU2IJA1KexOSAzixdQf7j czVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=MXRSo7Bfbe6lDlHCJm+CIISENbRdG4l7siPy76JG7SU=; b=bNaGJK3mVaT7ERq+tbFyJn4ig2sJJbgp2ouvYF6vPSHlADBjK+TZpkVWldBwnW4Dvf okC8sTJaIjbMsVPfhZJldMEDdxivICq/UKAhtz7tIcn1B3oYbKwKHvTL1ihhjs9R2jKB yUULX5R+rIcDuqOdfAlasx6O0CEx0Gf4JjG5rtyc6RNQCgyYK0Sj0jcEKPXmI9I5WcYf s20wiQzCSWXK7DBntYojCHl1dvwxE1whIz3IL/dQuTvml/5N0OYhc77a+irmS8YT4tQp WWGIBkkyEtvQbt8IjQB9WLdtvofJNu06cwPUq5PckzSspqhcPbIOUs/dsCsohQdsccWT /Cpw== X-Gm-Message-State: APjAAAXCifLuOzLS3xaV6PwqRK/DhjLR7RRfYrWKrPp3ha2y27GGLuG9 nqZbXq4mdC4rHNIJmjTbliaMfdw5AGc= X-Received: by 2002:a63:e44b:: with SMTP id i11mr11617071pgk.297.1567152429453; Fri, 30 Aug 2019 01:07:09 -0700 (PDT) Received: from LGEARND20B15 ([27.122.242.75]) by smtp.gmail.com with ESMTPSA id v189sm5854894pfv.176.2019.08.30.01.07.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2019 01:07:08 -0700 (PDT) Date: Fri, 30 Aug 2019 17:07:04 +0900 From: Austin Kim To: rex.zhu@amd.com, evan.quan@amd.com Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amdgpu: Move null pointer dereference check Message-ID: <20190830080704.GA29599@LGEARND20B15> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Null pointer dereference check should have been checked, ahead of below routine. struct amdgpu_device *adev = hwmgr->adev; With this commit, it could avoid potential NULL dereference. Signed-off-by: Austin Kim --- drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c index 8189fe4..4728aa2 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c @@ -722,16 +722,17 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr) static int smu8_start_smu(struct pp_hwmgr *hwmgr) { - struct amdgpu_device *adev = hwmgr->adev; + struct amdgpu_device *adev; uint32_t index = SMN_MP1_SRAM_START_ADDR + SMU8_FIRMWARE_HEADER_LOCATION + offsetof(struct SMU8_Firmware_Header, Version); - if (hwmgr == NULL || hwmgr->device == NULL) return -EINVAL; + adev = hwmgr->adev; + cgs_write_register(hwmgr->device, mmMP0PUB_IND_INDEX, index); hwmgr->smu_version = cgs_read_register(hwmgr->device, mmMP0PUB_IND_DATA); pr_info("smu version %02d.%02d.%02d\n", -- 2.6.2