aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.19.8/0644-drm-amd-amdgpu-Fix-debugfs-error-handling.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.19.8/0644-drm-amd-amdgpu-Fix-debugfs-error-handling.patch')
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.19.8/0644-drm-amd-amdgpu-Fix-debugfs-error-handling.patch60
1 files changed, 60 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.19.8/0644-drm-amd-amdgpu-Fix-debugfs-error-handling.patch b/common/recipes-kernel/linux/linux-yocto-4.19.8/0644-drm-amd-amdgpu-Fix-debugfs-error-handling.patch
new file mode 100644
index 00000000..6879898c
--- /dev/null
+++ b/common/recipes-kernel/linux/linux-yocto-4.19.8/0644-drm-amd-amdgpu-Fix-debugfs-error-handling.patch
@@ -0,0 +1,60 @@
+From 775ec1ac94c9fe765a0bbed61b71fd575b586df2 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Thu, 14 Jun 2018 17:45:23 +0300
+Subject: [PATCH 0644/2940] drm/amd/amdgpu: Fix debugfs error handling
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The error handling is wrong and "ent" could be NULL we when dereference
+it to get "ent->d_inode".
+
+The thing is that normally debugfs_create_file() is not supposed to
+require (or have) any error handling. That function does return error
+pointers if debugfs is turned off but we know it's enable here. When
+it's enabled, then it returns NULL on error.
+
+So what I did was I stripped out all the error handling except around
+the i_size_write(). I could have just used a NULL check instead of an
+IS_ERR_OR_NULL() but I figured this was more clear because that way you
+don't have to look at the surrounding code to see whether debugfs is
+enabled or not.
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Reviewed-by: Christian König <christian.koenig@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 12 ++----------
+ 1 file changed, 2 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+index f5fb93795a69..dd9a4fb9ce39 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+@@ -826,21 +826,13 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
+ {
+ struct drm_minor *minor = adev->ddev->primary;
+ struct dentry *ent, *root = minor->debugfs_root;
+- unsigned i, j;
++ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
+ ent = debugfs_create_file(debugfs_regs_names[i],
+ S_IFREG | S_IRUGO, root,
+ adev, debugfs_regs[i]);
+- if (IS_ERR(ent)) {
+- for (j = 0; j < i; j++) {
+- debugfs_remove(adev->debugfs_regs[i]);
+- adev->debugfs_regs[i] = NULL;
+- }
+- return PTR_ERR(ent);
+- }
+-
+- if (!i)
++ if (!i && !IS_ERR_OR_NULL(ent))
+ i_size_write(ent->d_inode, adev->rmmio_size);
+ adev->debugfs_regs[i] = ent;
+ }
+--
+2.17.1
+