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] [day] [month] [year] [list]
Message-ID: <12823935.O9o76ZdvQC@rafael.j.wysocki>
Date: Wed, 21 Jan 2026 11:57:26 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Hans de Goede <hansg@...nel.org>,
 Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
 Linux ACPI <linux-acpi@...r.kernel.org>,
 Kenneth Chan <kenneth.t.chan@...il.com>, platform-driver-x86@...r.kernel.org,
 Azael Avalos <coproscefalo@...il.com>,
 Matthew Garrett <matthew.garrett@...ula.com>
Subject:
 [PATCH v2 2/2] platform/x86: toshiba_haps: Fix memory leaks in add/remove
 routines

On Tuesday, January 20, 2026 4:44:23 PM CET Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> 
> toshiba_haps_add() leaks the haps object allocated by it if it returns
> an error after allocating that object successfully.
> 
> toshiba_haps_remove() does not free the object pointed to by
> toshiba_haps before clearing that pointer, so it becomes unreachable
> allocated memory.
> 
> Address these memory leaks by freeing the memory in question as
> appropriate.

Actually, this one can use devm_kzalloc() for allocating memory instead,
so here's a v2.

---
From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
Subject: [PATCH v2 2/2] platform/x86: toshiba_haps: Fix memory leaks in add/remove routines

toshiba_haps_add() leaks the haps object allocated by it if it returns
an error after allocating that object successfully.

toshiba_haps_remove() does not free the object pointed to by
toshiba_haps before clearing that pointer, so it becomes unreachable
allocated memory.

Address these memory leaks by using devm_kzalloc() for allocating
the memory in question.

Fixes: 23d0ba0c908a ("platform/x86: Toshiba HDD Active Protection Sensor")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
---

v1 -> v2:
   * Use devm_kzalloc() for memory allocation and drop the rest of the changes.

---
 drivers/platform/x86/toshiba_haps.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/platform/x86/toshiba_haps.c
+++ b/drivers/platform/x86/toshiba_haps.c
@@ -183,7 +183,7 @@ static int toshiba_haps_add(struct acpi_
 
 	pr_info("Toshiba HDD Active Protection Sensor device\n");
 
-	haps = kzalloc(sizeof(struct toshiba_haps_dev), GFP_KERNEL);
+	haps = devm_kzalloc(&acpi_dev->dev, sizeof(*haps), GFP_KERNEL);
 	if (!haps)
 		return -ENOMEM;
 




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ