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-next>] [day] [month] [year] [list]
Message-ID: <20220715071105.2321311-1-cuigaosheng1@huawei.com>
Date:   Fri, 15 Jul 2022 15:11:05 +0800
From:   Gaosheng Cui <cuigaosheng1@...wei.com>
To:     <cuigaosheng1@...wei.com>, <miquel.raynal@...tlin.com>,
        <richard@....at>, <vigneshr@...com>
CC:     <linux-mtd@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
        <gongruiqi1@...wei.com>, <wangweiyang2@...wei.com>
Subject: [PATCH -next] mtd/ftl: Fix memleak in ftl_add_mtd()

When add_mtd_blktrans_dev failed, partition's memory will be freed
by kfree, but there are some structure members that are allocated
for memory independently, such as partition->VirtualBlockMap,
partition->EUNInfo, partition->ZferInfo, and partition->bam_cache,
so kfree(partition) may cause memory leaks, using ftl_freepart(partition)
will fix it.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Gaosheng Cui <cuigaosheng1@...wei.com>
---
 drivers/mtd/ftl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index f655d2905270..200271bdc7aa 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -1031,6 +1031,7 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 		partition->mbd.devnum = -1;
 		if (!add_mtd_blktrans_dev(&partition->mbd))
 			return;
+		ftl_freepart(partition);
 	}
 
 	kfree(partition);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ