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: <46aa5810-8f5d-b35e-17a5-137228cb9720@users.sourceforge.net>
Date:   Wed, 11 Jan 2017 21:45:21 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     linux-mtd@...ts.infradead.org,
        Boris Brezillon <boris.brezillon@...e-electrons.com>,
        Brian Norris <computersforpeace@...il.com>,
        Cyrille Pitchen <cyrille.pitchen@...el.com>,
        David Woodhouse <dwmw2@...radead.org>,
        Denys Vlasenko <dvlasenk@...hat.com>,
        Marek Vasut <marek.vasut@...il.com>,
        Richard Weinberger <richard@....at>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH 10/18] mtd-cfi_cmdset_0002: One function call less in
 cfi_amdstd_setup() after error detection

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Wed, 11 Jan 2017 18:32:06 +0100

The kfree() function was called in one case by the cfi_amdstd_setup()
function during error handling even if the passed data structure member
contained a null pointer.

Adjust a jump target according to the Linux coding style convention
so that memory will be also released for members of a data structure
before the container "mtd" in the error handling case.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/mtd/chips/cfi_cmdset_0002.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 3bed67e35692..25d485f6d2ff 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -692,7 +692,7 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
 					  sizeof(*mtd->eraseregions),
 					  GFP_KERNEL);
 	if (!mtd->eraseregions)
-		goto setup_err;
+		goto free_priv;
 
 	for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
 		unsigned long ernum, ersize;
@@ -721,9 +721,10 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
 
  setup_err:
 	kfree(mtd->eraseregions);
-	kfree(mtd);
+free_priv:
 	kfree(cfi->cmdset_priv);
 	kfree(cfi->cfiq);
+	kfree(mtd);
 	return NULL;
 }
 
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ