]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
platform/x86: toshiba_haps: Fix memory leaks in add/remove routines
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 26 Jan 2026 14:38:45 +0000 (16:38 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 26 Jan 2026 14:38:45 +0000 (16:38 +0200)
commit128497456756e1b952bd5a912cd073836465109d
tree26a2880bdbc5aae16af3b34e26e6ee967876fcba
parent43b0b7eff4b3fb684f257d5a24376782e9663465
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@intel.com>
drivers/platform/x86/toshiba_haps.c