Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966308AbcJFIyd (ORCPT ); Thu, 6 Oct 2016 04:54:33 -0400 Received: from mout.web.de ([212.227.17.12]:58191 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965853AbcJFIy3 (ORCPT ); Thu, 6 Oct 2016 04:54:29 -0400 Subject: [PATCH 02/54] md/raid0: Less function calls in create_strip_zones() after error detection To: linux-raid@vger.kernel.org, Christoph Hellwig , Guoqing Jiang , Jens Axboe , Mike Christie , Neil Brown , Shaohua Li , Tomasz Majchrzak References: <566ABCD9.1060404@users.sourceforge.net> <786843ef-4b6f-eb04-7326-2f6f5b408826@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <95367971-fdc2-7bb8-e34e-bf54e480420d@users.sourceforge.net> Date: Thu, 6 Oct 2016 10:53:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <786843ef-4b6f-eb04-7326-2f6f5b408826@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:M0vbP0KRjFvixO3sGcPvkQT7In4tR6lEOsJJ0n7JCQiKjc71/ru stHXj0OVrmWqMAfsARmuuSNoIIwMc/oChO0wj4RwoijXi/IVpMWuo1jpDwICf83MEP69Sjw 1zeRzbtaweTGLMm8XgfZkYuCfSftnmy0MNPBMccmdSrCo+eh/ALasCw++WzHZcMYmKr8QQu DzNaqTdCeCxBwv8AX5LJA== X-UI-Out-Filterresults: notjunk:1;V01:K0:kuQgNarkxM8=:BjUrsEQimI041JCqcFkt22 1PteN7+5FUcgm8trn4IIblxVsrsRdU3q+UaJR0B8Vo+PokDpR0qzq4obo6gIevby40dOLywSr mbrScxX21aZzIndY1bYbcQnPCQnzFOeyXSKicsEOaPr3o3mqxACEdk8QYH5FLp+B+z8wj+/R6 j+FIR6Sr/ymdFy9uDs2tFiuW2vJHAv6f4vteb+xuREws4/kR+NgCBx60YfqK5ayEpbcAZEq7D 6RItpEqanfYlsv5ok7N1LZRSiZel0UzNOCO8fdh0ykY1p3YdtpZl/WZkZY0xZn+C0YF1AVEm2 k9IMMNHjgxsZ/S+t1Ma+MO6H4xkKwdviqwEcoeofqzXMufM0njfzNQVdVt4veID3TecfmZoWX RreGVFpYIZypCMzUH6Bq9OL4dt98yzQGzvYNTYoasevkbQS3h+S6ruCQFfczLkA0Xd11QJ+Ih M2EMG1JvY1Ys3xNgpf1AqKHrF+IaKAbxLqOmqakjtZrFjYbsvs1k/5DvtKxJFqtv2RV9WcOue viOy8OkpUZpEF5EiV37OJ+6GyH9uKWjmWHhSemodlaKLslM03XY1wW384AYDaNOn7Q64HWJoF J3wmdpHqOZBESsn07QqUaULie2zyIKcRGY1qT3xMedLJqmXpKSjTO/7cQe3Vi1A6pdiFtwzCY KUBW32LbnHrythWzP2AttwkYy8qVJKpDRlI13pcNZS+Kj0ywaw4xE12MesFebqRzP50Jq6qRK 5sCxW1/aHqMhwf+1bW44QCgJnCyaQgWgiok66ISI8NtEEI95QhR05VtTgodXk1XeTu57uyP74 /5HB+83 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2794 Lines: 88 From: Markus Elfring 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 --- 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