From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC0652BCF4C; Mon, 9 Feb 2026 14:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648623; cv=none; b=Bxc6fg3F0moOBsbl4UEwTgW+NV2p2RywV7+fFIhGP/gXFJ/2K3QFUkkXBQgB8oZpUoruwUnI+AzcUCSWrhBoaSW+/BEMgZbXpeijz7JMmZHy/mZFDvshvQqG0VI2JMwNKdlWjPccPO+69xAJFoBuN7PlRGxpk9hF4kxygDZSKcI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648623; c=relaxed/simple; bh=7SFSWECa8lVF2zhupyQKq+9G4TspcbqB+QUV2DlgRYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kYK6hch+nUEaYG5/OhDfWsY05pCs4gATAZTYlYxXPM+w2gYm2llGd2lvT+4WTN9um+B8WPk4BeiA7ZS/fOdUDv5oMg9MXf1jTsAt223cNCH4MsCnnBKE4L6Q/96EVbvVc1arLgHMXGAfl3bWIhsnf2A2b/pqyy4INT4pNyacr1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AupUFbyd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AupUFbyd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24E06C116C6; Mon, 9 Feb 2026 14:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770648623; bh=7SFSWECa8lVF2zhupyQKq+9G4TspcbqB+QUV2DlgRYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AupUFbydQ46xV+XiogOzMimB0/G81NkrSLO0wf9mT5OTY4iICa4WwVuqp+7d2YR/t JTOAfel0KGoIWYYTx0+C97/CnVtlequkOy3r503pZAhjjvcvYP5SXPfVmjKhpt7lt6 DHhG2K0cuqVr3CsdXmHG0FdD96WyF/gKUREU3XQ4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.6 56/86] platform/x86: toshiba_haps: Fix memory leaks in add/remove routines Date: Mon, 9 Feb 2026 15:24:19 +0100 Message-ID: <20260209142306.795564057@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142304.770150175@linuxfoundation.org> References: <20260209142304.770150175@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki [ 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 Signed-off-by: Sasha Levin --- drivers/platform/x86/toshiba_haps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c index 8c9f76286b080..f2292d2412fd1 100644 --- 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_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; -- 2.51.0