diff options
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.19.8/1676-drm-amdgpu-Fix-some-sanity-check.patch')
-rw-r--r-- | common/recipes-kernel/linux/linux-yocto-4.19.8/1676-drm-amdgpu-Fix-some-sanity-check.patch | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.19.8/1676-drm-amdgpu-Fix-some-sanity-check.patch b/common/recipes-kernel/linux/linux-yocto-4.19.8/1676-drm-amdgpu-Fix-some-sanity-check.patch new file mode 100644 index 00000000..3cec481d --- /dev/null +++ b/common/recipes-kernel/linux/linux-yocto-4.19.8/1676-drm-amdgpu-Fix-some-sanity-check.patch @@ -0,0 +1,106 @@ +From cba18c09daa0f6ba9dbe6c328abaa1a8a3657c0b Mon Sep 17 00:00:00 2001 +From: xinhui pan <xinhui.pan@amd.com> +Date: Tue, 19 Mar 2019 11:16:32 +0800 +Subject: [PATCH 1676/2940] drm/amdgpu: Fix some sanity check + +ras context might be NULL, so move con->h_data after check !con +also fix sizeof wrong type while at it. + +Signed-off-by: xinhui pan <xinhui.pan@amd.com> +Reviewed-by: Alex Deucher <alexander.deucher@amd.com> +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 24 +++++++++++++++++------- + 1 file changed, 17 insertions(+), 7 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +index a71668b8a7d0..a2ab70a24314 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +@@ -270,7 +270,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f, + data->inject.value = value; + } + } else { +- if (size < sizeof(data)) ++ if (size < sizeof(*data)) + return -EINVAL; + + if (copy_from_user(data, buf, sizeof(*data))) +@@ -1208,14 +1208,15 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, + unsigned long *bps, int pages) + { + struct amdgpu_ras *con = amdgpu_ras_get_context(adev); +- struct ras_err_handler_data *data = con->eh_data; ++ struct ras_err_handler_data *data; + int i = pages; + int ret = 0; + +- if (!con || !data || !bps || pages <= 0) ++ if (!con || !con->eh_data || !bps || pages <= 0) + return 0; + + mutex_lock(&con->recovery_lock); ++ data = con->eh_data; + if (!data) + goto out; + +@@ -1239,15 +1240,18 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, + int amdgpu_ras_reserve_bad_pages(struct amdgpu_device *adev) + { + struct amdgpu_ras *con = amdgpu_ras_get_context(adev); +- struct ras_err_handler_data *data = con->eh_data; ++ struct ras_err_handler_data *data; + uint64_t bp; + struct amdgpu_bo *bo; + int i; + +- if (!con || !data) ++ if (!con || !con->eh_data) + return 0; + + mutex_lock(&con->recovery_lock); ++ data = con->eh_data; ++ if (!data) ++ goto out; + /* reserve vram at driver post stage. */ + for (i = data->last_reserved; i < data->count; i++) { + bp = data->bps[i].bp; +@@ -1259,6 +1263,7 @@ int amdgpu_ras_reserve_bad_pages(struct amdgpu_device *adev) + data->bps[i].bo = bo; + data->last_reserved = i + 1; + } ++out: + mutex_unlock(&con->recovery_lock); + return 0; + } +@@ -1267,14 +1272,18 @@ int amdgpu_ras_reserve_bad_pages(struct amdgpu_device *adev) + static int amdgpu_ras_release_bad_pages(struct amdgpu_device *adev) + { + struct amdgpu_ras *con = amdgpu_ras_get_context(adev); +- struct ras_err_handler_data *data = con->eh_data; ++ struct ras_err_handler_data *data; + struct amdgpu_bo *bo; + int i; + +- if (!con || !data) ++ if (!con || !con->eh_data) + return 0; + + mutex_lock(&con->recovery_lock); ++ data = con->eh_data; ++ if (!data) ++ goto out; ++ + for (i = data->last_reserved - 1; i >= 0; i--) { + bo = data->bps[i].bo; + +@@ -1283,6 +1292,7 @@ static int amdgpu_ras_release_bad_pages(struct amdgpu_device *adev) + data->bps[i].bo = bo; + data->last_reserved = i; + } ++out: + mutex_unlock(&con->recovery_lock); + return 0; + } +-- +2.17.1 + |