[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b48403b0-7eb2-cfeb-33bd-1996e838559a@users.sourceforge.net>
Date: Thu, 6 Oct 2016 11:11:14 +0200
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: linux-raid@...r.kernel.org, Christoph Hellwig <hch@....de>,
Guoqing Jiang <gqjiang@...e.com>, Jens Axboe <axboe@...com>,
Mike Christie <mchristi@...hat.com>,
Neil Brown <neilb@...e.com>, Shaohua Li <shli@...nel.org>,
Tomasz Majchrzak <tomasz.majchrzak@...el.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org,
Julia Lawall <julia.lawall@...6.fr>
Subject: [PATCH 15/54] md/raid1: Less function calls in setup_conf() after
error detection
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 4 Oct 2016 18:01:02 +0200
Resource release functions were called in up to four cases
by the setup_conf() function during error handling even if
the passed data structure members contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
drivers/md/raid1.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4d2fcbc..7dc45ba 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2786,19 +2786,19 @@ static struct r1conf *setup_conf(struct mddev *mddev)
GFP_KERNEL);
if (!conf->mirrors) {
err = -ENOMEM;
- goto abort;
+ goto free_conf;
}
conf->tmppage = alloc_page(GFP_KERNEL);
if (!conf->tmppage) {
err = -ENOMEM;
- goto abort;
+ goto free_mirrors;
}
conf->poolinfo = kzalloc(sizeof(*conf->poolinfo), GFP_KERNEL);
if (!conf->poolinfo) {
err = -ENOMEM;
- goto abort;
+ goto put_page;
}
conf->poolinfo->raid_disks = mddev->raid_disks * 2;
@@ -2807,7 +2807,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
conf->poolinfo);
if (!conf->r1bio_pool) {
err = -ENOMEM;
- goto abort;
+ goto free_poolinfo;
}
conf->poolinfo->mddev = mddev;
@@ -2825,7 +2825,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
if (disk->rdev) {
err = -EINVAL;
- goto abort;
+ goto destroy_pool;
}
disk->rdev = rdev;
@@ -2866,7 +2866,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
if (!test_bit(In_sync, &disk->rdev->flags)) {
/* Original is not in_sync - bad */
err = -EIO;
- goto abort;
+ goto destroy_pool;
}
}
}
@@ -2886,16 +2886,19 @@ static struct r1conf *setup_conf(struct mddev *mddev)
"md/raid1:%s: couldn't allocate thread\n",
mdname(mddev));
err = -ENOMEM;
- goto abort;
+ goto destroy_pool;
}
return conf;
-
- abort:
+destroy_pool:
mempool_destroy(conf->r1bio_pool);
+free_poolinfo:
kfree(conf->poolinfo);
+put_page:
safe_put_page(conf->tmppage);
+free_mirrors:
kfree(conf->mirrors);
+free_conf:
kfree(conf);
return ERR_PTR(err);
}
--
2.10.1
Powered by blists - more mailing lists