Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794062318; b=uMGY5xoWev5nhh+Nv1EIWtQzxfv8eZoL6d3pq8fgsikQ3jZ/1O8JtLKynkpLlAVynPIR AXyT5tstl2I7VuCwoevtRV3/adRFQ62QQIfscTLaj74K5YKj0fYKHMXmix9x9646bMpyk duyfXKBTB8otoT0bPkNUycz1j/rbG3/rX3vA/5RKm9pEiGEM1+hu0IwtS2uw6fbJSAESe AxHoasQ+fFhKzYcdwgbCNsw2TTW+hrqb4g77qgVZIEgBgaAGMaM/w89nTpqFeBi7tmGmE 8+HwxRt/NGYjpdrl0DC/n7t9V9hpvOG0piLJL0oDAJoQudBddJv1sMx8jFwxKW3gnTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794062318; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=up/ZqV9WJRPn4kSRN2C1Ge7J3fv9ZRo/9x9Rs2cohqU=; b=YEWa9zBtpa8nKEl52xgsr5uqEvapA5X3uI87q5Lvcryxo5osXldvzylLsJ/ddzGvLQBD +lqU9iYlck1No40c9RDZdEm+4FxRrPjXrsopFEKYi3o9TDMq4u0IOIG2ThJ3ecPO0e/T4 +zBxTe8UPc4iaZgOSCV47ub3XPjCat+ieZ7yApDBOGgtaN6PKlSYm64604UgCNvFGVw5Y eSjHGJkcnBVbFgqGFSD5+irXEbufMp7Z7LqUa3HvoqBj71ZJhoztDXu9Djpb9XPfD5H8s FLzNIyG9qceeuEtcvkx3yN6y15b/JTl8AJeVSl3OAZ1/kvsuuNFLwKZ5vS36d5eCdRg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="0OTW5TH/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F43C606A643; Sat, 7 Nov 2026 14:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0OTW5TH/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id C13151F0089F; Sat, 7 Nov 2026 14:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794062318; bh=up/ZqV9WJRPn4kSRN2C1Ge7J3fv9ZRo/9x9Rs2cohqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0OTW5TH//RVBsawq9i/eBThULmpU2j+nOyCwrOzfso1dU6o2Q2YLrpLA7isNmTfdh niTTxO+VuNq3x6TxzZmVZa5QZb8Kqdjj9bD6VxP0HsRGTYOeuPtWl9r0iX92rxPZQg vJ/l3IlDbofVsaZobZN1WVG9h/B8cObUiTtgDS0I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guangshuo Li , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 6.12 1252/1536] platform/x86: simatic-ipc: fix platform device leak on registration failure Date: Sat, 7 Nov 2026 08:54:28 -0500 Message-ID: <20261107135032.935969831@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134957.653319350@linuxfoundation.org> References: <20261107134957.653319350@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li [ Upstream commit 9523698252fd583d6987582b9c34ec6500d10986 ] register_platform_devices() registers the battery, LED, and watchdog platform devices in sequence. If LED registration fails, the battery device remains registered. If watchdog registration fails, the LED and battery devices remain registered. These failure paths leave successful platform_device_register_data() calls without the matching platform_device_unregister() calls. Add an unwind ladder to unregister previously registered platform devices in reverse order before returning the registration error. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fixes: dd123e62bded ("platform/x86: simatic-ipc: add main driver for Siemens devices") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li Link: https://patch.msgid.link/20260924115617.1578309-1-lgs201920130244@gmail.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen Signed-off-by: Sasha Levin --- drivers/platform/x86/siemens/simatic-ipc.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/siemens/simatic-ipc.c b/drivers/platform/x86/siemens/simatic-ipc.c index 7039874d8f112..4a4509fc9263e 100644 --- a/drivers/platform/x86/siemens/simatic-ipc.c +++ b/drivers/platform/x86/siemens/simatic-ipc.c @@ -92,6 +92,7 @@ static int register_platform_devices(u32 station_id) u8 wdtmode = SIMATIC_IPC_DEVICE_NONE; u8 battmode = SIMATIC_IPC_DEVICE_NONE; char *pdevname; + int ret; int i; for (i = 0; i < ARRAY_SIZE(device_modes); i++) { @@ -139,8 +140,10 @@ static int register_platform_devices(u32 station_id) pdevname, PLATFORM_DEVID_NONE, &platform_data, sizeof(struct simatic_ipc_platform)); - if (IS_ERR(ipc_led_platform_device)) - return PTR_ERR(ipc_led_platform_device); + if (IS_ERR(ipc_led_platform_device)) { + ret = PTR_ERR(ipc_led_platform_device); + goto err_unregister_batt; + } pr_debug("device=%s created\n", ipc_led_platform_device->name); @@ -153,8 +156,10 @@ static int register_platform_devices(u32 station_id) KBUILD_MODNAME "_wdt", PLATFORM_DEVID_NONE, &platform_data, sizeof(struct simatic_ipc_platform)); - if (IS_ERR(ipc_wdt_platform_device)) - return PTR_ERR(ipc_wdt_platform_device); + if (IS_ERR(ipc_wdt_platform_device)) { + ret = PTR_ERR(ipc_wdt_platform_device); + goto err_unregister_led; + } pr_debug("device=%s created\n", ipc_wdt_platform_device->name); @@ -169,6 +174,14 @@ static int register_platform_devices(u32 station_id) } return 0; + +err_unregister_led: + if (ledmode != SIMATIC_IPC_DEVICE_NONE) + platform_device_unregister(ipc_led_platform_device); +err_unregister_batt: + if (battmode != SIMATIC_IPC_DEVICE_NONE) + platform_device_unregister(ipc_batt_platform_device); + return ret; } static void request_additional_modules(u32 station_id) -- 2.53.0