linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix memory leak in do_walk_down
@ 2016-09-14  2:02 Liu Bo
  2016-09-14 13:19 ` Holger Hoffstätte
  2016-09-22 15:10 ` David Sterba
  0 siblings, 2 replies; 5+ messages in thread
From: Liu Bo @ 2016-09-14  2:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The extent buffer 'next' needs to be free'd conditionally.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/extent-tree.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5a940ab..779fd72 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -8882,6 +8882,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
 				       &wc->flags[level - 1]);
 	if (ret < 0) {
 		btrfs_tree_unlock(next);
+		free_extent_buffer(next);
 		return ret;
 	}
 
-- 
2.5.5

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

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

* Re: [PATCH] Btrfs: fix memory leak in do_walk_down
  2016-09-14  2:02 [PATCH] Btrfs: fix memory leak in do_walk_down Liu Bo
@ 2016-09-14 13:19 ` Holger Hoffstätte
  2016-09-22 15:01   ` David Sterba
  2016-09-22 15:10 ` David Sterba
  1 sibling, 1 reply; 5+ messages in thread
From: Holger Hoffstätte @ 2016-09-14 13:19 UTC (permalink / raw)
  To: Liu Bo, linux-btrfs; +Cc: David Sterba, Josef Bacik

On 09/14/16 04:02, Liu Bo wrote:
> The extent buffer 'next' needs to be free'd conditionally.
> 
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> ---
>  fs/btrfs/extent-tree.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 5a940ab..779fd72 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -8882,6 +8882,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
>  				       &wc->flags[level - 1]);
>  	if (ret < 0) {
>  		btrfs_tree_unlock(next);
> +		free_extent_buffer(next);
>  		return ret;
>  	}
>  
> 

This was fixed a long time ago by the following patch by Josef:

"Btrfs: don't BUG() during drop snapshot"
https://patchwork.kernel.org/patch/7002791/

..which never got merged. I've been using it since 4.1.x until today
without problems.

Note that apparently Patchwork got confused here: downloading only the
"patch" fragment won't work; you'll need the full "mbox" attachment.
It also seems to have been sorted into the wrong list bucket for some
reason.

-h


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

* Re: [PATCH] Btrfs: fix memory leak in do_walk_down
  2016-09-14 13:19 ` Holger Hoffstätte
@ 2016-09-22 15:01   ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2016-09-22 15:01 UTC (permalink / raw)
  To: Holger Hoffstätte; +Cc: Liu Bo, linux-btrfs, David Sterba, Josef Bacik

On Wed, Sep 14, 2016 at 03:19:18PM +0200, Holger Hoffstätte wrote:
> On 09/14/16 04:02, Liu Bo wrote:
> > The extent buffer 'next' needs to be free'd conditionally.
> > 
> > Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> > ---
> >  fs/btrfs/extent-tree.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> > index 5a940ab..779fd72 100644
> > --- a/fs/btrfs/extent-tree.c
> > +++ b/fs/btrfs/extent-tree.c
> > @@ -8882,6 +8882,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
> >  				       &wc->flags[level - 1]);
> >  	if (ret < 0) {
> >  		btrfs_tree_unlock(next);
> > +		free_extent_buffer(next);
> >  		return ret;
> >  	}
> >  
> > 
> 
> This was fixed a long time ago by the following patch by Josef:
> 
> "Btrfs: don't BUG() during drop snapshot"
> https://patchwork.kernel.org/patch/7002791/
> 
> ..which never got merged.

The patch was buried in some thread, not even a subject gives a hint
there's a patch, but anyway thanks for pointing it out.

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

* Re: [PATCH] Btrfs: fix memory leak in do_walk_down
  2016-09-14  2:02 [PATCH] Btrfs: fix memory leak in do_walk_down Liu Bo
  2016-09-14 13:19 ` Holger Hoffstätte
@ 2016-09-22 15:10 ` David Sterba
  2016-09-22 17:57   ` Liu Bo
  1 sibling, 1 reply; 5+ messages in thread
From: David Sterba @ 2016-09-22 15:10 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs, David Sterba

On Tue, Sep 13, 2016 at 07:02:27PM -0700, Liu Bo wrote:
> The extent buffer 'next' needs to be free'd conditionally.
> 
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>

Reviewed-by: David Sterba <dsterba@suse.com>

Josef's patch contained this fix but mixed with other (removing BUG_ON).
I've removed it so we can merge both patches, for sake of better change
separation.

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

* Re: [PATCH] Btrfs: fix memory leak in do_walk_down
  2016-09-22 15:10 ` David Sterba
@ 2016-09-22 17:57   ` Liu Bo
  0 siblings, 0 replies; 5+ messages in thread
From: Liu Bo @ 2016-09-22 17:57 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs

On Thu, Sep 22, 2016 at 05:10:25PM +0200, David Sterba wrote:
> On Tue, Sep 13, 2016 at 07:02:27PM -0700, Liu Bo wrote:
> > The extent buffer 'next' needs to be free'd conditionally.
> > 
> > Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> 
> Reviewed-by: David Sterba <dsterba@suse.com>
> 
> Josef's patch contained this fix but mixed with other (removing BUG_ON).
> I've removed it so we can merge both patches, for sake of better change
> separation.

Good to know that, thank you for the efforts.

Thanks,

-liubo

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

end of thread, other threads:[~2016-09-22 17:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-14  2:02 [PATCH] Btrfs: fix memory leak in do_walk_down Liu Bo
2016-09-14 13:19 ` Holger Hoffstätte
2016-09-22 15:01   ` David Sterba
2016-09-22 15:10 ` David Sterba
2016-09-22 17:57   ` Liu Bo

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