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.

BUG=b/484728121
TEST=presubmit
RELEASE_NOTE=Fixed CVE-2026-23176 in the Linux kernel.

cos-patch: security-moderate
Fixes: 23d0ba0c908a ("platform/x86: Toshiba HDD Active Protection Sensor")
Change-Id: Ie94cd93ae69ccbdfdac8adda82d96c4d3e4e4525
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Angel Adetula <angeladetula@google.com>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/133286
Main-Branch-Verified: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Reviewed-by: He Gao <hegao@google.com>
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/133866
1 file changed