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]
Date:   Thu, 6 Oct 2016 11:29:09 +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 29/54] md/raid5: Return directly after a failed kcalloc() in
 alloc_thread_groups()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Wed, 5 Oct 2016 08:54:40 +0200

The kfree() function was called in up to two cases
by the alloc_thread_groups() function during error handling
even if the passed variable contained a null pointer.

* Return directly after a call of the kcalloc() function failed
  at the beginning.

* Simplify a condition check for memory allocation failures.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/md/raid5.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index b624ba6..d864871 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6265,10 +6265,12 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt,
 	}
 	*group_cnt = num_possible_nodes();
 	workers = kcalloc(cnt * *group_cnt, sizeof(*workers), GFP_NOIO);
+	if (!workers)
+		return -ENOMEM;
+
 	*worker_groups = kcalloc(*group_cnt, sizeof(**worker_groups), GFP_NOIO);
-	if (!*worker_groups || !workers) {
+	if (!*worker_groups) {
 		kfree(workers);
-		kfree(*worker_groups);
 		return -ENOMEM;
 	}
 
-- 
2.10.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ