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 7B48B1E497; Thu, 23 May 2024 13:19:14 +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=1716470354; cv=none; b=pMHT87K+9DfOC85frmrCJsc35Xgj+fWY/MvCGdRglnka8BZhlBAPVwEGVk5xR752qR8fY6qCYpyLbLSQUnTQHj8mXmHZFDv7EjeXhJy3jMtGYy4CF/u6959qzRGZEuPeF66B4AsAdRN+w/DsZId8/QW1nZIxuWwMhDV+aZktHNg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716470354; c=relaxed/simple; bh=emW3GIWvbtXENMUS/L4Y3q2kITijpYUR3lvcIXdHnmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K0D2WZ0+l5pW1PoVHHsacX1tcee6T5W6Do8D8O66HWchosf1//StV/C3VQlo4EAdXfHb4hpEwvEdF1A5wLn5r/nG2JG2CGFGX6Hq3nmNAOfxMk9Ijj0K9JpPK5SPOttOcimm/sSk7oXP9Qny+2ckJm2T+MQVTo+WufyFMRrO5K4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xeEuaHTm; 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="xeEuaHTm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02665C3277B; Thu, 23 May 2024 13:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716470354; bh=emW3GIWvbtXENMUS/L4Y3q2kITijpYUR3lvcIXdHnmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xeEuaHTmQK0BcNaoHTShKiPSCXz7TiL1Ztej4Z2wjOkIkC9d8kpVDgij+IiydvAwF Ibj09anMFpOOtCgxJajQMSq4PG8loqn7LjT7PPs8RlSbecpqPubeHkmJD3gIhVrmpQ A9cIVtgZlK4mSSBEuy363qvrQ0YL0/pO6CCi5QnU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hawking Zhang , Tao Zhou , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Srinivasan Shanmugam , Ajay Kaher Subject: [PATCH 5.15 16/23] drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper() Date: Thu, 23 May 2024 15:13:12 +0200 Message-ID: <20240523130328.566298893@linuxfoundation.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240523130327.956341021@linuxfoundation.org> References: <20240523130327.956341021@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Srinivasan Shanmugam commit b8d55a90fd55b767c25687747e2b24abd1ef8680 upstream. Return invalid error code -EINVAL for invalid block id. Fixes the below: drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1183 amdgpu_ras_query_error_status_helper() error: we previously assumed 'info' could be null (see line 1176) Suggested-by: Hawking Zhang Cc: Tao Zhou Cc: Hawking Zhang Cc: Christian König Cc: Alex Deucher Signed-off-by: Srinivasan Shanmugam Reviewed-by: Hawking Zhang Signed-off-by: Alex Deucher [Ajay: applied AMDGPU_RAS_BLOCK_COUNT condition to amdgpu_ras_query_error_status() as amdgpu_ras_query_error_status_helper() not present in v5.15 amdgpu_ras_query_error_status_helper() was introduced in 8cc0f5669eb6] Signed-off-by: Ajay Kaher Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -820,6 +820,9 @@ int amdgpu_ras_query_error_status(struct if (!obj) return -EINVAL; + if (!info || info->head.block == AMDGPU_RAS_BLOCK_COUNT) + return -EINVAL; + switch (info->head.block) { case AMDGPU_RAS_BLOCK__UMC: if (adev->umc.ras_funcs &&