All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Modify error handling
@ 2016-08-04 15:44 Amitoj Kaur Chawla
  0 siblings, 0 replies; only message in thread
From: Amitoj Kaur Chawla @ 2016-08-04 15:44 UTC (permalink / raw)
  To: airlied, dri-devel, linux-kernel; +Cc: julia.lawall

To indicate an error, debugfs_create_file can return an ERR_PTR for
!CONFIG_DEBUG_FS and NULL otherwise, so in case the result is
dereferenced there should be a previous IS_ERR and a NULL check.

The Coccinelle semantic patch used to find the issue is as follows:
@@
expression e;
identifier f;
@@

*  e = debugfs_create_file(...);
... when != e == NULL
e->f

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 6553146..4c1a2bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2143,6 +2143,8 @@ static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 				  adev, &amdgpu_debugfs_regs_fops);
 	if (IS_ERR(ent))
 		return PTR_ERR(ent);
+	if (!ent)
+		return -ENOMEM;
 	i_size_write(ent->d_inode, adev->rmmio_size);
 	adev->debugfs_regs = ent;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-04 15:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-04 15:44 [PATCH] drm/amdgpu: Modify error handling Amitoj Kaur Chawla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.