From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CEF655304DD; Wed, 23 Sep 2026 14:31:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790173900; cv=none; b=NPD4H7D7B5uKdMXNGiptp9xz+Z4t4mWwN/02/84P5VKJ1Oq6Uu+3tK8ukqvmpWOjKyj/kg05X1GfYf0BgYsPfAp6ezo2Lv4gRnjDvrn3l7nKkTD7GUyv7NTUXQvpZGk5kYs9cu2FGt2B4K/4q/TXcCnn2CUb4ktxrMoJRK1dmwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790173900; c=relaxed/simple; bh=SiHLEilvhlGz2zytO5CDHAP6LuX7NFDaztgtS7aK5dQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PF8HV42iFYA8C9W1UWi8F5HJUKYpNf/rmCf9Tx4kTEHFLAEuAh4ZSJU891VdJN3XS1STHDCjFur90uYnW3e/SCuzfLMaax49X1Nwv0J50xJXyR6hGcJqm6XL4ZgMQOJrhH1D8tvSvO4ncJAt6pi8HHwOovpV1N5ngfk3YVxInN0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FP9IYzKI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FP9IYzKI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6509D1F000FF; Wed, 23 Sep 2026 14:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790173899; bh=Hd959jnCl0kzQnfovL2ZFYLHDxDSTqJ30251VN0ruYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FP9IYzKIDxkqw/DwQfM2oJFT4eY5QszHv8sVbTTQKlCBca6A5kJzqapMdIYiRrUPr 8WqsTfSijMGZtCDajJ2BSzuJG5X60iUgvMWfwwkiNtKqI7guKuNXMcgQdvr8SfmaQX cI01Bn6UBbnznTS0H1Xb6UzuBeiczggy+fTMJiDw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wentao Liang , Guenter Roeck Subject: [PATCH 7.2 380/438] watchdog: sp5100_tco: Fix pci_dev reference leak in sp5100_tco_init() Date: Wed, 23 Sep 2026 16:06:41 +0200 Message-ID: <20260923140654.716345418@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923140644.756254324@linuxfoundation.org> References: <20260923140644.756254324@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wentao Liang commit 88f113634028ca90a857031837d8061d1a9e1a7b upstream. sp5100_tco_init() stores the PCI device matched by for_each_pci_dev() in the global sp5100_tco_pci and keeps its reference for the lifetime of the driver, but neither sp5100_tco_exit() nor the error paths of sp5100_tco_init() call pci_dev_put(), leaking the reference on driver registration failure and on every module load/unload cycle. Drop the reference when the platform driver or device registration fails and when the module is unloaded. Fixes: 15e28bf13008 ("watchdog: Add support for sp5100 chipset TCO") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang Link: https://patch.msgid.link/20260916170511.2086199-1-vulab@iscas.ac.cn Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/sp5100_tco.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -605,8 +605,10 @@ static int __init sp5100_tco_init(void) pr_info("SP5100/SB800 TCO WatchDog Timer Driver\n"); err = platform_driver_register(&sp5100_tco_driver); - if (err) + if (err) { + pci_dev_put(sp5100_tco_pci); return err; + } sp5100_tco_platform_device = platform_device_register_simple(TCO_DRIVER_NAME, -1, NULL, 0); @@ -619,6 +621,7 @@ static int __init sp5100_tco_init(void) unreg_platform_driver: platform_driver_unregister(&sp5100_tco_driver); + pci_dev_put(sp5100_tco_pci); return err; } @@ -626,6 +629,7 @@ static void __exit sp5100_tco_exit(void) { platform_device_unregister(sp5100_tco_platform_device); platform_driver_unregister(&sp5100_tco_driver); + pci_dev_put(sp5100_tco_pci); } module_init(sp5100_tco_init);