linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: raid56: avoid double allocation
@ 2013-07-25  0:09 Andi Shyti
  2013-07-25  8:18 ` Liu Bo
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Shyti @ 2013-07-25  0:09 UTC (permalink / raw)
  To: chris.mason; +Cc: linux-btrfs, linux-kernel, andi

alloc_rbio frees already bbio and raid_map, therefore they don't
need to be freed in case it fails

Signed-off-by: Andi Shyti <andi@etezian.org>
---
 fs/btrfs/raid56.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 0525e13..35fe775 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1687,11 +1687,9 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio,
 	struct blk_plug_cb *cb;
 
 	rbio = alloc_rbio(root, bbio, raid_map, stripe_len);
-	if (IS_ERR(rbio)) {
-		kfree(raid_map);
-		kfree(bbio);
+	if (IS_ERR(rbio))
 		return PTR_ERR(rbio);
-	}
+
 	bio_list_add(&rbio->bio_list, bio);
 	rbio->bio_list_bytes = bio->bi_size;
 
-- 
1.8.3.2


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

* Re: [PATCH] btrfs: raid56: avoid double allocation
  2013-07-25  0:09 [PATCH] btrfs: raid56: avoid double allocation Andi Shyti
@ 2013-07-25  8:18 ` Liu Bo
  2013-07-25  8:26   ` Miao Xie
  0 siblings, 1 reply; 3+ messages in thread
From: Liu Bo @ 2013-07-25  8:18 UTC (permalink / raw)
  To: Andi Shyti; +Cc: chris.mason, linux-btrfs, linux-kernel

On Thu, Jul 25, 2013 at 02:09:40AM +0200, Andi Shyti wrote:
> alloc_rbio frees already bbio and raid_map, therefore they don't
> need to be freed in case it fails
> 

Looks good to me.

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

> Signed-off-by: Andi Shyti <andi@etezian.org>
> ---
>  fs/btrfs/raid56.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index 0525e13..35fe775 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -1687,11 +1687,9 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio,
>  	struct blk_plug_cb *cb;
>  
>  	rbio = alloc_rbio(root, bbio, raid_map, stripe_len);
> -	if (IS_ERR(rbio)) {
> -		kfree(raid_map);
> -		kfree(bbio);
> +	if (IS_ERR(rbio))
>  		return PTR_ERR(rbio);
> -	}
> +
>  	bio_list_add(&rbio->bio_list, bio);
>  	rbio->bio_list_bytes = bio->bi_size;
>  
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
-liubo

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

* Re: [PATCH] btrfs: raid56: avoid double allocation
  2013-07-25  8:18 ` Liu Bo
@ 2013-07-25  8:26   ` Miao Xie
  0 siblings, 0 replies; 3+ messages in thread
From: Miao Xie @ 2013-07-25  8:26 UTC (permalink / raw)
  To: bo.li.liu; +Cc: Andi Shyti, chris.mason, linux-btrfs, linux-kernel

On 	thu, 25 Jul 2013 16:18:41 +0800, Liu Bo wrote:
> On Thu, Jul 25, 2013 at 02:09:40AM +0200, Andi Shyti wrote:
>> alloc_rbio frees already bbio and raid_map, therefore they don't
>> need to be freed in case it fails
>>
> 
> Looks good to me.
> 
> Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Dan Carpenter has fixed this problem in patch
https://patchwork.kernel.org/patch/2831091/

Thanks
Miao

> 
>> Signed-off-by: Andi Shyti <andi@etezian.org>
>> ---
>>  fs/btrfs/raid56.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
>> index 0525e13..35fe775 100644
>> --- a/fs/btrfs/raid56.c
>> +++ b/fs/btrfs/raid56.c
>> @@ -1687,11 +1687,9 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio,
>>  	struct blk_plug_cb *cb;
>>  
>>  	rbio = alloc_rbio(root, bbio, raid_map, stripe_len);
>> -	if (IS_ERR(rbio)) {
>> -		kfree(raid_map);
>> -		kfree(bbio);
>> +	if (IS_ERR(rbio))
>>  		return PTR_ERR(rbio);
>> -	}
>> +
>>  	bio_list_add(&rbio->bio_list, bio);
>>  	rbio->bio_list_bytes = bio->bi_size;
>>  
>> -- 
>> 1.8.3.2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> -liubo
> --
> 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:[~2013-07-25  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-25  0:09 [PATCH] btrfs: raid56: avoid double allocation Andi Shyti
2013-07-25  8:18 ` Liu Bo
2013-07-25  8:26   ` Miao Xie

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