mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple@vodafone.de>
To: Amitoj Kaur Chawla <amitoj1606@gmail.com>,
	airlied@linux.ie, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Cc: julia.lawall@lip6.fr
Subject: Re: [PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm
Date: Fri, 5 Aug 2016 10:04:03 +0200	[thread overview]
Message-ID: <743b4921-e44f-a1b4-a217-dd77a7a6ce2e@vodafone.de> (raw)
In-Reply-To: <20160804154255.GA12191@amitoj-Inspiron-3542>

Am 04.08.2016 um 17:42 schrieb Amitoj Kaur Chawla:
> 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>

The whole section is surrounded by CONFIG_DEBUG_FS, so I suggest to just 
replace the check or IS_ERR with a NULL check.

Regards,
Christian.

> ---
>   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;
>   

      reply	other threads:[~2016-08-05  8:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 15:42 Amitoj Kaur Chawla
2016-08-05  8:04 ` Christian König [this message]

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=743b4921-e44f-a1b4-a217-dd77a7a6ce2e@vodafone.de \
    --to=deathsimple@vodafone.de \
    --cc=airlied@linux.ie \
    --cc=amitoj1606@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®