linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: dereferencing error pointer in btrfs_quota_enable()
@ 2018-08-02  8:44 Dan Carpenter
  2018-08-02 10:22 ` Nikolay Borisov
  2018-08-02 13:34 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-08-02  8:44 UTC (permalink / raw)
  To: Chris Mason, Nikolay Borisov
  Cc: Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

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>

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;
 	}
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: dereferencing error pointer in btrfs_quota_enable()
  2018-08-02  8:44 [PATCH] btrfs: dereferencing error pointer in btrfs_quota_enable() Dan Carpenter
@ 2018-08-02 10:22 ` Nikolay Borisov
  2018-08-02 13:34 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2018-08-02 10:22 UTC (permalink / raw)
  To: Dan Carpenter, Chris Mason
  Cc: Josef Bacik, David Sterba, linux-btrfs, kernel-janitors



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;
>  	}
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: dereferencing error pointer in btrfs_quota_enable()
  2018-08-02  8:44 [PATCH] btrfs: dereferencing error pointer in btrfs_quota_enable() Dan Carpenter
  2018-08-02 10:22 ` Nikolay Borisov
@ 2018-08-02 13:34 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2018-08-02 13:34 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Chris Mason, Nikolay Borisov, Josef Bacik, David Sterba,
	linux-btrfs, kernel-janitors

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-02 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-02  8:44 [PATCH] btrfs: dereferencing error pointer in btrfs_quota_enable() Dan Carpenter
2018-08-02 10:22 ` Nikolay Borisov
2018-08-02 13:34 ` David Sterba

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).