Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1456509

[PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm

From Amitoj Kaur Chawla <amitoj1606@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm
Date 2016-08-04 18:00 +0200
Message-ID <s2tdT-2TC-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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_ttm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 8a1752f..9ff70a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1198,6 +1198,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
 				  adev, &amdgpu_ttm_vram_fops);
 	if (IS_ERR(ent))
 		return PTR_ERR(ent);
+	if (!ent)
+		return -ENOMEM;
 	i_size_write(ent->d_inode, adev->mc.mc_vram_size);
 	adev->mman.vram = ent;
 
@@ -1205,6 +1207,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
 				  adev, &amdgpu_ttm_gtt_fops);
 	if (IS_ERR(ent))
 		return PTR_ERR(ent);
+	if (!ent)
+		return -ENOMEM;
 	i_size_write(ent->d_inode, adev->mc.gtt_size);
 	adev->mman.gtt = ent;
 
-- 
1.9.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-08-04 18:00 +0200
  Re: [PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm Christian König <deathsimple@vodafone.de> - 2016-08-05 10:10 +0200

csiph-web