Re: [PATCH] efivarfs: Eliminate dead code in efivarfs_create()

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

 



On 2016-02-24 at 17:47:34 +0100, Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx> wrote:
> 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@xxxxxxxxxx>
> > ---
> >  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!

Ping, this doesn't seem to have made it into Linus' tree, linux-next or
your publicly accessible tree yet. It seems the patch still applies, or
should I resubmit it?
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux