diff options
| author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2026-01-26 16:38:45 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-02-11 13:35:31 +0100 |
| commit | 5bce10f0f9435afaae3fc4df9a52b01d9b3853dc (patch) | |
| tree | d145f3adc28c858b0e1bfa142d1c79a7c67b0603 | |
| parent | 193f087207ad8756e5f308ec0ad7b457e518d77e (diff) | |
| download | linux-5bce10f0f9435afaae3fc4df9a52b01d9b3853dc.tar.gz linux-5bce10f0f9435afaae3fc4df9a52b01d9b3853dc.tar.bz2 linux-5bce10f0f9435afaae3fc4df9a52b01d9b3853dc.zip | |
platform/x86: toshiba_haps: Fix memory leaks in add/remove routines
[ Upstream commit 128497456756e1b952bd5a912cd073836465109d ]
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@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | drivers/platform/x86/toshiba_haps.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c index 49e84095bb01..8a53f6119fed 100644 --- a/drivers/platform/x86/toshiba_haps.c +++ b/drivers/platform/x86/toshiba_haps.c @@ -185,7 +185,7 @@ static int toshiba_haps_add(struct acpi_device *acpi_dev) 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; |
