diff mbox

Btrfs: checking for NULL instead of IS_ERR

Message ID 20180531062111.374pq6lxrmdffun6@kili.mountain (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter May 31, 2018, 6:21 a.m. UTC
memdup_user() returns error pointers, it doesn't return NULL.

Fixes: 01141b08dee5 ("btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Misono Tomohiro May 31, 2018, 6:41 a.m. UTC | #1
Thanks again.

David, could you apply this on top of my v7 patch in for-next tree?

Regards,
Tomohiro Misono

On 2018/05/31 15:21, Dan Carpenter wrote:
> memdup_user() returns error pointers, it doesn't return NULL.
> 
> Fixes: 01141b08dee5 ("btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index ff5018587bd9..d8dd4504bdab 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -2791,9 +2791,9 @@ static noinline int btrfs_ioctl_get_subvol_rootref(struct file *file,
>  		return -ENOMEM;
>  
>  	rootrefs = memdup_user(argp, sizeof(*rootrefs));
> -	if (!rootrefs) {
> +	if (IS_ERR(rootrefs)) {
>  		btrfs_free_path(path);
> -		return -ENOMEM;
> +		return PTR_ERR(rootrefs);
>  	}
>  
>  	inode = file_inode(file);
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba May 31, 2018, 9:19 a.m. UTC | #2
On Thu, May 31, 2018 at 03:41:41PM +0900, Misono Tomohiro wrote:
> David, could you apply this on top of my v7 patch in for-next tree?

Done.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ff5018587bd9..d8dd4504bdab 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2791,9 +2791,9 @@  static noinline int btrfs_ioctl_get_subvol_rootref(struct file *file,
 		return -ENOMEM;
 
 	rootrefs = memdup_user(argp, sizeof(*rootrefs));
-	if (!rootrefs) {
+	if (IS_ERR(rootrefs)) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		return PTR_ERR(rootrefs);
 	}
 
 	inode = file_inode(file);