diff mbox series

btrfs: dereferencing error pointer in btrfs_quota_enable()

Message ID 20180802084428.k2uemow7k6j3us47@kili.mountain (mailing list archive)
State New, archived
Headers show
Series btrfs: dereferencing error pointer in btrfs_quota_enable() | expand

Commit Message

Dan Carpenter Aug. 2, 2018, 8:44 a.m. UTC
The error handling in "goto out;" expects that if "trans" is non-NULL
that means it's valid.  Unfortunately it could also be an error pointer.

Fixes: c9a6fe84fe43 ("btrfs: qgroups: Move transaction management inside btrfs_quota_enable/disable")
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

Nikolay Borisov Aug. 2, 2018, 10:22 a.m. UTC | #1
On  2.08.2018 11:44, Dan Carpenter wrote:
> The error handling in "goto out;" expects that if "trans" is non-NULL
> that means it's valid.  Unfortunately it could also be an error pointer.
> 
> Fixes: c9a6fe84fe43 ("btrfs: qgroups: Move transaction management inside btrfs_quota_enable/disable")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>


Good catch !

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 3a9019928329..380ff978defa 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -904,6 +904,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
>  	trans = btrfs_start_transaction(tree_root, 2);
>  	if (IS_ERR(trans)) {
>  		ret = PTR_ERR(trans);
> +		trans = NULL;
>  		goto out;
>  	}
>  
> 
--
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 Aug. 2, 2018, 1:34 p.m. UTC | #2
On Thu, Aug 02, 2018 at 11:44:29AM +0300, Dan Carpenter wrote:
> The error handling in "goto out;" expects that if "trans" is non-NULL
> that means it's valid.  Unfortunately it could also be an error pointer.
> 
> Fixes: c9a6fe84fe43 ("btrfs: qgroups: Move transaction management inside btrfs_quota_enable/disable")

Thanks, folded to the patch as it's still in the development branch.
--
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 series

Patch

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 3a9019928329..380ff978defa 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -904,6 +904,7 @@  int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
 	trans = btrfs_start_transaction(tree_root, 2);
 	if (IS_ERR(trans)) {
 		ret = PTR_ERR(trans);
+		trans = NULL;
 		goto out;
 	}