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: <20220704125922.2240585-1-niejianglei2021@163.com>
Date:   Mon,  4 Jul 2022 20:59:22 +0800
From:   Jianglei Nie <niejianglei2021@....com>
To:     iwona.winiarska@...el.com
Cc:     openbmc@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        Jianglei Nie <niejianglei2021@....com>
Subject: [PATCH] peci: fix potential memory leak in devm_adev_add()

devm_adev_add() allocates a memory chunk for "adev" and "adev->name"
with adev_alloc(). When auxiliary_device_add() fails, the function calls
auxiliary_device_uninit(), which doesn't release the allocated "adev"
and "adev->name", thus leading to a memory leak bug.

We should call adev_release() instead of auxiliary_device_uninit() to
release the "adev" and "adev->name".

Signed-off-by: Jianglei Nie <niejianglei2021@....com>
---
 drivers/peci/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/peci/cpu.c b/drivers/peci/cpu.c
index 68eb61c65d34..de865997ccde 100644
--- a/drivers/peci/cpu.c
+++ b/drivers/peci/cpu.c
@@ -248,7 +248,7 @@ static int devm_adev_add(struct device *dev, int idx)
 
 	ret = auxiliary_device_add(adev);
 	if (ret) {
-		auxiliary_device_uninit(adev);
+		adev_release(&adev->dev);
 		return ret;
 	}
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ