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 4ECA91487FA; Tue, 23 Jan 2024 01:08:03 +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=1705972083; cv=none; b=YBoTObN479aoxroQ/cfWrocnZD4srpP2UGVtNP9uINu/l1TAm47qKyzWfePI/2qJAjeKEquqHvtZiPSFxwYqj1uepu5RpnoAYs/A5EFgPM/6I1uIKiBfxm02v9fyIEPKpTb0g9VHdTecCuOeo720xkrj7rItzb2wYP4s7rzwaAQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705972083; c=relaxed/simple; bh=QWEJU3os0IWg0dW+O0Yk6OW7xyH4i6RQlsBz4xCxjxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q6MRX/mBy1F02Z/L0ZCPlnPyMOB51gMF8ONidyX3WVAoo2RfFOKV6jT/wWtdIJ5LajdCUCXA0evkXncBNQcfltkgwfABezK3wyo3SgNhT8z1ABdTZILBKKWIU1oWsXZKnzStDxR3hS6VhI2qV1F/hrUT6lgRaZAPhx7xSNq79Po= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=S5mRvmaV; 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="S5mRvmaV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB61CC433B1; Tue, 23 Jan 2024 01:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705972082; bh=QWEJU3os0IWg0dW+O0Yk6OW7xyH4i6RQlsBz4xCxjxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S5mRvmaVv6t+/0FjMfkFeW1nXFmxShBnQa6+IrEYlfZI61b56IumOrvu6Tfo6atRS Z5IS1jfNh361k5HI7ks4KJuI6fgCv2HJ6O678oHMm9Nh19onqFEfXpjLyA6GP3rVQX qy4ryJyiOGKYM2ySC79n2X5wYqGHoPdl58XevVJs= 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 5.15 007/374] drm/amdgpu: Fix cat debugfs amdgpu_regs_didt causes kernel null pointer Date: Mon, 22 Jan 2024 15:54:23 -0800 Message-ID: <20240122235744.882639643@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235744.598274724@linuxfoundation.org> References: <20240122235744.598274724@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 5.15-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 beb199d13451..632d8df04ef4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -342,6 +342,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); @@ -401,6 +404,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