[patch] drm/amdgpu: checking for IS_ERR() instead of NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Debugfs_ functions return an error pointer if debugfs is disabled in the
config and NULL on failure.  They are designed so that normally you
don't need to check for errors but here we dereference "ent" so we do
need.

This function has an #if defined(CONFIG_DEBUG_FS) so we know the
debugfs_create_file() can only return NULL and not an error pointer.

Fixes: d38ceaf99ed0 ('drm/amdgpu: add core driver (v4)')
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index d3706a4..06cb508 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1176,15 +1176,15 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
 
 	ent = debugfs_create_file("amdgpu_vram", S_IFREG | S_IRUGO, root,
 				  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;
 
 	ent = debugfs_create_file("amdgpu_gtt", S_IFREG | S_IRUGO, root,
 				  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;
 
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux