[PATCH] drm/amdgpu: add missed return value set for error case

Zhang, Hawking Hawking.Zhang at amd.com
Mon Dec 23 05:48:47 UTC 2019

[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>

-----Original Message-----
From: Chen, Guchun <Guchun.Chen at amd.com> 
Sent: Monday, December 23, 2019 12:42
To: Zhou1, Tao <Tao.Zhou1 at amd.com>; Zhang, Hawking <Hawking.Zhang at amd.com>; Li, Dennis <Dennis.Li at amd.com>; amd-gfx at lists.freedesktop.org
Cc: Chen, Guchun <Guchun.Chen at amd.com>
Subject: [PATCH] drm/amdgpu: add missed return value set for error case

Return value should be set when going to error handle tag for error case, this can avoid potential invalid array access by upper caller.

Signed-off-by: Guchun Chen <guchun.chen at amd.com>
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 3f4ba408aee0..511b137d9d5a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -1313,6 +1313,7 @@ static int amdgpu_ras_badpages_read(struct amdgpu_device *adev,
 	data = con->eh_data;
 	if (!data || data->count == 0) {
 		*bps = NULL;
+		ret = -EINVAL;
 		goto out;

More information about the amd-gfx mailing list