Re: [PATCH] shmem: using goto to replace several return

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

 



On Tue, 8 Mar 2011 17:15:00 +0800
Bob Liu <lliubbo@xxxxxxxxx> wrote:

> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1847,17 +1847,13 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
>  						     &dentry->d_name, NULL,
>  						     NULL, NULL);
>  		if (error) {
> -			if (error != -EOPNOTSUPP) {
> -				iput(inode);
> -				return error;
> -			}
> +			if (error != -EOPNOTSUPP)
> +				goto failed_iput;
>  		}
>  #ifdef CONFIG_TMPFS_POSIX_ACL
>  		error = generic_acl_init(inode, dir);
> -		if (error) {
> -			iput(inode);
> -			return error;
> -		}
> +		if (error)
> +			goto failed_iput;
>  #else
>  		error = 0;
>  #endif
> @@ -1866,6 +1862,9 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
>  		d_instantiate(dentry, inode);
>  		dget(dentry); /* Extra count - pin the dentry in core */
>  	}
> +
> +failed_iput:
> +	iput(inode);
>  	return error;
>  }

This adds a big bug: we newly do iput() on the non-error path.

Please, we need much more care and testing than this.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


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