linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix extent map leak during fallocate error path
@ 2017-04-04  2:20 fdmanana
  2017-04-05 11:54 ` David Sterba
  2017-04-18  3:58 ` Liu Bo
  0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2017-04-04  2:20 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

If the call to btrfs_qgroup_reserve_data() failed, we were leaking an
extent map structure. The failure can happen either due to an -ENOMEM
condition or, when quotas are enabled, due to -EDQUOT for example.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 48dfb8e..56304c4 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2856,8 +2856,10 @@ static long btrfs_fallocate(struct file *file, int mode,
 			}
 			ret = btrfs_qgroup_reserve_data(inode, cur_offset,
 					last_byte - cur_offset);
-			if (ret < 0)
+			if (ret < 0) {
+				free_extent_map(em);
 				break;
+			}
 		} else {
 			/*
 			 * Do not need to reserve unwritten extent for this
-- 
2.7.0.rc3


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

* Re: [PATCH] Btrfs: fix extent map leak during fallocate error path
  2017-04-04  2:20 [PATCH] Btrfs: fix extent map leak during fallocate error path fdmanana
@ 2017-04-05 11:54 ` David Sterba
  2017-04-18  3:58 ` Liu Bo
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2017-04-05 11:54 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Tue, Apr 04, 2017 at 03:20:36AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If the call to btrfs_qgroup_reserve_data() failed, we were leaking an
> extent map structure. The failure can happen either due to an -ENOMEM
> condition or, when quotas are enabled, due to -EDQUOT for example.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

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

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

* Re: [PATCH] Btrfs: fix extent map leak during fallocate error path
  2017-04-04  2:20 [PATCH] Btrfs: fix extent map leak during fallocate error path fdmanana
  2017-04-05 11:54 ` David Sterba
@ 2017-04-18  3:58 ` Liu Bo
  1 sibling, 0 replies; 3+ messages in thread
From: Liu Bo @ 2017-04-18  3:58 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Tue, Apr 04, 2017 at 03:20:36AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If the call to btrfs_qgroup_reserve_data() failed, we were leaking an
> extent map structure. The failure can happen either due to an -ENOMEM
> condition or, when quotas are enabled, due to -EDQUOT for example.
>

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>  fs/btrfs/file.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 48dfb8e..56304c4 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2856,8 +2856,10 @@ static long btrfs_fallocate(struct file *file, int mode,
>  			}
>  			ret = btrfs_qgroup_reserve_data(inode, cur_offset,
>  					last_byte - cur_offset);
> -			if (ret < 0)
> +			if (ret < 0) {
> +				free_extent_map(em);
>  				break;
> +			}
>  		} else {
>  			/*
>  			 * Do not need to reserve unwritten extent for this
> -- 
> 2.7.0.rc3
> 
> --
> 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

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

end of thread, other threads:[~2017-04-18  3:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-04  2:20 [PATCH] Btrfs: fix extent map leak during fallocate error path fdmanana
2017-04-05 11:54 ` David Sterba
2017-04-18  3:58 ` 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).