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=1795036494; b=OEDou+ehEgXjkiYzQA/6gGO58wgWeJTIkbbhwvdvt1twep/FWzlxx/f4lCiKAYvjnIuy hA8lPbL9/Bn/vbL+HjcLIziFFlvphetwNLWs2gJa4o4IcJtp8apZquoTnDmXCghFuNhyA HGQhnBGpFInJHGi7OY89c9f10paSa52JY1oA/xA7Chz7UCakGXu7YgCxLvxOLy6uMfX+J wl2vRaFcy8q2d5zp2UyfU/gb89l0ZtgqvZhI5HqtGrW2849p1hL6taFT3xfZdP2DDOcOg DB8KR+WMsMuLjEcYA4+03rv1zZn+/oxIxiqVlLOvDBfrbeNq/foZqCYk/9W9ht37M8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795036494; 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=7RIjNjGAhOXWeadvMAghe8q1FUOk+0TcSkee0Qq1VIs=; b=sqDucxnNUvMcgdHGv3eDA68lNFHUkhR6TjR5sJ7LM1aesFwd57FtKFrCrZC0fugoeu/o p5B3xOqivupOICzP2jwHm48IZyI4SZCZB1rBM07q1LO7W9/NX+fP54V29dv7ok/gGsASS fpJf0DwmlXlqwta4qJ3LEs+sMksg0P/TDwsK9EOt6HSE0YLrsf4g8lpl+w+SEZVcalh+m 7CWE45JwmIBUfE7ypRHA3ngD2rQuNxHhGKl96YxXFCRCUZrE9Pgwy7vpKoFzPLn5wZduQ 4pduzxSik6dLvx9hpnL0baoz3Q0NoQ+99zQsaZyPiURn3a4svXeM4m/k5OzUm5ecdFA== 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=PfPT04hV; 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 B253B606A31C; Wed, 18 Nov 2026 21:14:54 +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=PfPT04hV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DD291F000C7; Wed, 18 Nov 2026 21:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795036494; bh=7RIjNjGAhOXWeadvMAghe8q1FUOk+0TcSkee0Qq1VIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PfPT04hVkAyTnG6cF0mYCzmviwHuzhUefTjZHCGh7ItGCQQM2lS7H5fgCSUatCcP4 +kQXNU+76jhZstJ+4tvrcgyMp0jHW8Pk8SNmG0grssUoXLrkrcVY+Xb/0DnX3bWAP1 YStuY1W1wTjrjxX9nP6FjS6gRzhZJ2ykLoHtmq7o= 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.6 1080/3318] platform/x86: simatic-ipc: fix platform device leak on registration failure Date: Wed, 18 Nov 2026 15:28:22 +0100 Message-ID: <20261118150352.369497614@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@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.6-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 8ca6e277fa038..ebe7978e0c7b4 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