linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
To: Tobias Klauser <tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
Cc: Matthew Garrett
	<matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org>,
	Jeremy Kerr <jk-mnsaURCQ41sdnm+yROfE0A@public.gmane.org>,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] efivarfs: Eliminate dead code in efivarfs_create()
Date: Wed, 24 Feb 2016 16:47:34 +0000	[thread overview]
Message-ID: <20160224164734.GC2603@codeblueprint.co.uk> (raw)
In-Reply-To: <1456243630-24834-1-git-send-email-tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>

On Tue, 23 Feb, at 05:07:10PM, Tobias Klauser wrote:
> After commit ed8b0de5a33d ("efi: Make efivarfs entries immutable by
> default"), inode will always be NULL in the error check before iput(),
> thus remove the check and the call to iput() alltogether. Also directly
> fold the error handling code into the only place it is needed, which
> makes the code a bit smaller.
> 
> Found by the Coverity scanner (CID 1353443).
> 
> Signed-off-by: Tobias Klauser <tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
> ---
>  fs/efivarfs/inode.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
> index e2ab6d0497f2..43321c9cd71b 100644
> --- a/fs/efivarfs/inode.c
> +++ b/fs/efivarfs/inode.c
> @@ -106,7 +106,7 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
>  {
>  	struct inode *inode = NULL;
>  	struct efivar_entry *var;
> -	int namelen, i = 0, err = 0;
> +	int namelen, i = 0;
>  	bool is_removable = false;
>  
>  	if (!efivarfs_valid_name(dentry->d_name.name, dentry->d_name.len))
> @@ -128,8 +128,8 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
>  
>  	inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0, is_removable);
>  	if (!inode) {
> -		err = -ENOMEM;
> -		goto out;
> +		kfree(var);
> +		return -ENOMEM;
>  	}
>  
>  	for (i = 0; i < namelen; i++)
> @@ -142,13 +142,8 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
>  	efivar_entry_add(var, &efivarfs_list);
>  	d_instantiate(dentry, inode);
>  	dget(dentry);
> -out:
> -	if (err) {
> -		kfree(var);
> -		if (inode)
> -			iput(inode);
> -	}
> -	return err;
> +
> +	return 0;
>  }
>  
>  static int efivarfs_unlink(struct inode *dir, struct dentry *dentry)

Looks good to me. Thanks, applied!

  parent reply	other threads:[~2016-02-24 16:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-23 16:07 [PATCH] efivarfs: Eliminate dead code in efivarfs_create() Tobias Klauser
     [not found] ` <1456243630-24834-1-git-send-email-tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
2016-02-24 16:47   ` Matt Fleming [this message]
     [not found]     ` <20160224164734.GC2603-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-07-19 11:06       ` Tobias Klauser
     [not found]         ` <20160719110614.GA23998-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
2016-07-21 11:28           ` Matt Fleming

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=20160224164734.GC2603@codeblueprint.co.uk \
    --to=matt-mf/unelci9gs6ibeejttw/xrex20p6io@public.gmane.org \
    --cc=jk-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org \
    --cc=pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.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;
as well as URLs for NNTP newsgroup(s).