Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2970156rdb; Mon, 4 Dec 2023 12:36:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiGNG4BSxjINT7sQ79er9qc9iCCQjM3zRVpAG4V9Mbvp7XITeBA5snHxfVoJn7JhCtnLJ4 X-Received: by 2002:a17:902:ab5c:b0:1d0:6ffd:6104 with SMTP id ij28-20020a170902ab5c00b001d06ffd6104mr330830plb.38.1701722206696; Mon, 04 Dec 2023 12:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701722206; cv=none; d=google.com; s=arc-20160816; b=k/lTKOLqxEI9zJEAqLmDt9C0yYFGS2kisP7QSQQjljwRssB2CDQJID+OAQiAH6W3LC fCeZVaptQyEXeliA859CwI8mUABd9eMCYKTH5nvPPl8vtBWHQrnu9ITWgZiz+TrwTelk wyVe1ANoj1DdKzHT1Y7olZdtSNVPVzpV2HZH4Al6tCs+PP+6JjMkwrbdwufYumCSw4vu zZ1BQ6Dpf0sVPe8kOCxQB/75yPjnMatZADEF56HxwGX8t3C2oMDiODIZXA3wi8ybVkON Av6tXLJdVA535U50ECncpRV30XrBBIxiJdx/01h0dg+MqKlaO98ntWpNHOXBs5XiZmfP 4Xsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WrOsF2JrSr1d0UWkFQQVDQwN77b1fJpDl8kJ249CIcQ=; fh=TckTlre0iJrwGMTi1zfqMJIjt0xnE9zCqcar+4MEs2Q=; b=K16DSj0+B529XX8mCyG4Bri+B6sXyLnPtSJbdybCbBR2Jy77I/X46jQZKDPYrBhU3i cqODsZglXRNcMjd6colAPUEUguOebrYpgzK0hudXwtR3hMOIC1lqYKvVVNAvxtl443Zi jknIsa34HiNO9oeQnufeROOkWoJUQ5BRGf5Hf8hfdUiZwvp72jUWE4bCg4zGnIEmIrae yUN+q4gdIDwB7onsGHrRFtyMlvUHbk3mQkaJQcLK27i7xZEEn7vNZprUHVWQIQ68RNKB LM13NzcmEj3QqiVZWu69aqhmn162zD2jA7ryKpYyMPkp82LFG1TDcsxt/XpaEP4sweze NVOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ljKnSPqN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id o1-20020a170902d4c100b001cfcc0f484asi8519268plg.464.2023.12.04.12.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:36:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ljKnSPqN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 852FF8083ADF; Mon, 4 Dec 2023 12:36:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235556AbjLDUgX (ORCPT + 99 others); Mon, 4 Dec 2023 15:36:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235562AbjLDUgF (ORCPT ); Mon, 4 Dec 2023 15:36:05 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1E4E26B6 for ; Mon, 4 Dec 2023 12:34:43 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB67CC433CC; Mon, 4 Dec 2023 20:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701722083; bh=k/eO7LGISg54yqT0LpW/yAwLh4UIjlzQkCpseZx4mv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ljKnSPqNKZvfOO1I7xScvuX6VeZp1LyeuklkFsi1MYpUbSqdNoTJ7a91v1SmKavZR eCmzjuKVXihmFwAB+fAj19zSPnU9Pp4U81YyxmMg9VPQ317tSHKXngmAZL1r0boKav FR+3+YFuzbtFzwzTenHIBe1BeqFL90yB5mCdloAxnXgnZp4+TtVYLEWyt8IyLc15y8 zICBXhf7W/CKiEqmlblbeTKisXEJt53RrEq1w4UCaWfXdRuM2dv26KNdzfTepeXTad 0GTUQmPCn+zZiwAgdEnfIq6xr9+A//xCwYLE3B0fy9xe0BnYyJG0LhRujCOm35/6es nItgzCEw9yg8Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lu Yao , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin , Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, shashank.sharma@amd.com, Hawking.Zhang@amd.com, srinivasan.shanmugam@amd.com, dan.carpenter@linaro.org, suhui@nfschina.com, andrealmeid@igalia.com, tom.stdenis@amd.com, le.ma@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.6 26/32] drm/amdgpu: Fix cat debugfs amdgpu_regs_didt causes kernel null pointer Date: Mon, 4 Dec 2023 15:32:46 -0500 Message-ID: <20231204203317.2092321-26-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204203317.2092321-1-sashal@kernel.org> References: <20231204203317.2092321-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.4 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 12:36:41 -0800 (PST) From: Lu Yao [ Upstream commit 2161e09cd05a50d80736fe397145340d2e8f6c05 ] For 'AMDGPU_FAMILY_SI' family cards, in 'si_common_early_init' func, init 'didt_rreg' and 'didt_wreg' to 'NULL'. But in func 'amdgpu_debugfs_regs_didt_read/write', using 'RREG32_DIDT' 'WREG32_DIDT' lacks of relevant judgment. And other 'amdgpu_ip_block_version' that use these two definitions won't be added for 'AMDGPU_FAMILY_SI'. So, add null pointer judgment before calling. Reviewed-by: Christian König Signed-off-by: Lu Yao Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index 05405da51e7a2..3f2126f99923e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -638,6 +638,9 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf, if (size & 0x3 || *pos & 0x3) return -EINVAL; + if (!adev->didt_rreg) + return -EOPNOTSUPP; + r = pm_runtime_get_sync(adev_to_drm(adev)->dev); if (r < 0) { pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); @@ -694,6 +697,9 @@ static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user if (size & 0x3 || *pos & 0x3) return -EINVAL; + if (!adev->didt_wreg) + return -EOPNOTSUPP; + r = pm_runtime_get_sync(adev_to_drm(adev)->dev); if (r < 0) { pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); -- 2.42.0