All of lore.kernel.org
 help / color / mirror / Atom feed
* md/raid1: If md_integrity_register() failed,run() must  free the mem
@ 2012-03-23  2:30 majianpeng
  2012-03-27  2:18 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: majianpeng @ 2012-03-23  2:30 UTC (permalink / raw)
  To: Neil Brown; +Cc: linux-raid

From 8a7f9d02f3e7151ecfd05ca9b1734d6e62414c03 Mon Sep 17 00:00:00 2001
From: majianpeng <majianpeng@gmail.com>
Date: Fri, 23 Mar 2012 10:25:41 +0800
Subject: [PATCH] md/raid1: If md_integrity_register() failed,run() must  free
 the mem.


Signed-off-by: majianpeng <majianpeng@gmail.com>
---
 drivers/md/raid1.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4a40a20..f71d8a0 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2641,6 +2641,7 @@ static int run(struct mddev *mddev)
 	struct r1conf *conf;
 	int i;
 	struct md_rdev *rdev;
+	int ret;
 
 	if (mddev->level != 1) {
 		printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
@@ -2705,7 +2706,18 @@ static int run(struct mddev *mddev)
 		mddev->queue->backing_dev_info.congested_data = mddev;
 		blk_queue_merge_bvec(mddev->queue, raid1_mergeable_bvec);
 	}
-	return md_integrity_register(mddev);
+
+	ret =  md_integrity_register(mddev);
+	if (ret) {
+		md_unregister_thread(&mddev->thread);
+		if (conf->r1bio_pool)
+			mempool_destroy(conf->r1bio_pool);
+		kfree(conf->mirrors);
+		kfree(conf->poolinfo);
+		kfree(conf);
+		mddev->private = NULL;
+	}
+	return ret;
 }
 
 static int stop(struct mddev *mddev)
-- 
1.7.5.4

 				
--------------
majianpeng
2012-03-23


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

* Re: md/raid1: If md_integrity_register() failed,run() must  free the mem
  2012-03-23  2:30 md/raid1: If md_integrity_register() failed,run() must free the mem majianpeng
@ 2012-03-27  2:18 ` NeilBrown
  0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2012-03-27  2:18 UTC (permalink / raw)
  To: majianpeng; +Cc: linux-raid

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

On Fri, 23 Mar 2012 10:30:59 +0800 "majianpeng" <majianpeng@gmail.com> wrote:

> >From 8a7f9d02f3e7151ecfd05ca9b1734d6e62414c03 Mon Sep 17 00:00:00 2001
> From: majianpeng <majianpeng@gmail.com>
> Date: Fri, 23 Mar 2012 10:25:41 +0800
> Subject: [PATCH] md/raid1: If md_integrity_register() failed,run() must  free
>  the mem.
> 
> 
> Signed-off-by: majianpeng <majianpeng@gmail.com>
> ---
>  drivers/md/raid1.c |   14 +++++++++++++-
>  1 files changed, 13 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 4a40a20..f71d8a0 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -2641,6 +2641,7 @@ static int run(struct mddev *mddev)
>  	struct r1conf *conf;
>  	int i;
>  	struct md_rdev *rdev;
> +	int ret;
>  
>  	if (mddev->level != 1) {
>  		printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
> @@ -2705,7 +2706,18 @@ static int run(struct mddev *mddev)
>  		mddev->queue->backing_dev_info.congested_data = mddev;
>  		blk_queue_merge_bvec(mddev->queue, raid1_mergeable_bvec);
>  	}
> -	return md_integrity_register(mddev);
> +
> +	ret =  md_integrity_register(mddev);
> +	if (ret) {
> +		md_unregister_thread(&mddev->thread);
> +		if (conf->r1bio_pool)
> +			mempool_destroy(conf->r1bio_pool);
> +		kfree(conf->mirrors);
> +		kfree(conf->poolinfo);
> +		kfree(conf);
> +		mddev->private = NULL;
> +	}
> +	return ret;
>  }
>  
>  static int stop(struct mddev *mddev)


applied, thanks.

Again, I changed it to just call 'stop' instead of duplicating the code.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

end of thread, other threads:[~2012-03-27  2:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-23  2:30 md/raid1: If md_integrity_register() failed,run() must free the mem majianpeng
2012-03-27  2:18 ` NeilBrown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.