From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B340D22F16; Thu, 18 Jan 2024 10:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575521; cv=none; b=Dw4sCnPvKfMf+ydXdcJZd/jNJZiEl85Uj8Jv4+ro5jB/m+67GvJl9qA3OjXs3goWQfsfyAfuFPoRI/Tw6cFj5smwpCTW2axNi9DCvfmCk2KAoy3rOhm/ltLO/aAZeoay/Xgpnf02XJ/s5bq03KV1cKs/21LizzeqDuIzvU6GO8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575521; c=relaxed/simple; bh=78RXJPKUcZjND86/1sRhYmiyfwlvZ/gxOjuuuKE+NDM=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:User-Agent:X-stable: X-Patchwork-Hint:MIME-Version:Content-Type: Content-Transfer-Encoding; b=LxA+VJSgtUYQjDufmtUySNFzPYoJd9i98/B6iiU05FbWsJv9lO3+kS00ndeBNBcgKCgkQK3Gm7WPOr9MJZtTCpKZqrOmOMEp9QqlRNlRL5O4WoTbp4D+l91agiBXkUCAKdVOvjpTbb6J1FqeGQihdUcFzyMvvIi6TF8y/14UQYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EziXQnsX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="EziXQnsX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39071C433F1; Thu, 18 Jan 2024 10:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705575521; bh=78RXJPKUcZjND86/1sRhYmiyfwlvZ/gxOjuuuKE+NDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EziXQnsXz/Qrh7rJQwIg2SXy3l5SR5dCsh+EJAbp16ui0Rjec7mYYeej3wUIc3if6 jU9A943T8u+v2iL2IENN3cc14gvcns84wM6iN7Ll4qbt141Ni6HQLWMeyyLdGxlgdc mfSeXXlEowl/4DEDpRxxOhDm0xagvp3pfLt/YphI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Christian=20K=C3=B6nig?= , Lu Yao , Alex Deucher , Sasha Levin Subject: [PATCH 6.1 012/100] drm/amdgpu: Fix cat debugfs amdgpu_regs_didt causes kernel null pointer Date: Thu, 18 Jan 2024 11:48:20 +0100 Message-ID: <20240118104311.412396980@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118104310.892180084@linuxfoundation.org> References: <20240118104310.892180084@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ 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 fd796574f87a..8123feb1a116 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -479,6 +479,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); @@ -535,6 +538,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.43.0