lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <95367971-fdc2-7bb8-e34e-bf54e480420d@users.sourceforge.net>
Date:   Thu, 6 Oct 2016 10:53:29 +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 02/54] md/raid0: Less function calls in create_strip_zones()
 after error detection

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 4 Oct 2016 10:43:33 +0200

The kfree() function was called in up to two cases
by the create_strip_zones() function during error handling even if
the passed data structure member (or variable) 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/raid0.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 50e8a63..3c76451 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -146,7 +146,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		       mdname(mddev),
 		       mddev->chunk_sectors << 9, blksize);
 		err = -EINVAL;
-		goto abort;
+		goto free_conf;
 	}
 
 	err = -ENOMEM;
@@ -154,12 +154,12 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 				   sizeof(*conf->strip_zone),
 				   GFP_KERNEL);
 	if (!conf->strip_zone)
-		goto abort;
+		goto free_conf;
 	conf->devlist = kcalloc(conf->nr_strip_zones * mddev->raid_disks,
 				sizeof(*conf->devlist),
 				GFP_KERNEL);
 	if (!conf->devlist)
-		goto abort;
+		goto free_zone;
 
 	/* The first zone must contain all devices, so here we check that
 	 * there is a proper alignment of slots to devices and find them all
@@ -190,17 +190,17 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 			printk(KERN_ERR
 			       "md/raid0:%s: remove inactive devices before converting to RAID0\n",
 			       mdname(mddev));
-			goto abort;
+			goto free_device_list;
 		}
 		if (j >= mddev->raid_disks) {
 			printk(KERN_ERR "md/raid0:%s: bad disk number %d - "
 			       "aborting!\n", mdname(mddev), j);
-			goto abort;
+			goto free_device_list;
 		}
 		if (dev[j]) {
 			printk(KERN_ERR "md/raid0:%s: multiple devices for %d - "
 			       "aborting!\n", mdname(mddev), j);
-			goto abort;
+			goto free_device_list;
 		}
 		dev[j] = rdev1;
 
@@ -211,7 +211,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	if (cnt != mddev->raid_disks) {
 		printk(KERN_ERR "md/raid0:%s: too few disks (%d of %d) - "
 		       "aborting!\n", mdname(mddev), cnt, mddev->raid_disks);
-		goto abort;
+		goto free_device_list;
 	}
 	zone->nb_dev = cnt;
 	zone->zone_end = smallest->sectors * cnt;
@@ -271,9 +271,11 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	*private_conf = conf;
 
 	return 0;
-abort:
-	kfree(conf->strip_zone);
+free_device_list:
 	kfree(conf->devlist);
+free_zone:
+	kfree(conf->strip_zone);
+free_conf:
 	kfree(conf);
 	*private_conf = ERR_PTR(err);
 	return err;
-- 
2.10.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ