From: Dan Carpenter <dan.carpenter@oracle.com>
To: David Airlie <airlied@linux.ie>,
Alex Deucher <alexander.deucher@amd.com>
Cc: "Michel Dänzer" <michel.daenzer@amd.com>,
kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org,
"Maarten Lankhorst" <maarten.lankhorst@canonical.com>,
"Christian König" <christian.koenig@amd.com>,
"monk.liu" <monk.liu@amd.com>
Subject: [patch] drm/amdgpu: checking for IS_ERR() instead of NULL
Date: Thu, 11 Jun 2015 08:51:50 +0000 [thread overview]
Message-ID: <20150611085150.GB27090@mwanda> (raw)
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@oracle.com>
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;
reply other threads:[~2015-06-11 8:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150611085150.GB27090@mwanda \
--to=dan.carpenter@oracle.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=maarten.lankhorst@canonical.com \
--cc=michel.daenzer@amd.com \
--cc=monk.liu@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox