public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PNP: add a error handling in pnpacpi_init()
@ 2025-12-18  8:29 Haoxiang Li
  2025-12-18 11:33 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Haoxiang Li @ 2025-12-18  8:29 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, linux-kernel, Haoxiang Li, stable

Add a error handling for pnp_register_protocol(), and if
it fails, call put_device() to drop the device reference.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 drivers/pnp/pnpacpi/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index a0927081a003..0b63e1748b7c 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -304,7 +304,10 @@ static int __init pnpacpi_init(void)
 		return 0;
 	}
 	printk(KERN_INFO "pnp: PnP ACPI init\n");
-	pnp_register_protocol(&pnpacpi_protocol);
+	if (pnp_register_protocol(&pnpacpi_protocol)) {
+		put_device(&pnpacpi_protocol.dev);
+		return 0;
+	}
 	acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL);
 	printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num);
 	pnp_platform_devices = 1;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-18 13:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18  8:29 [PATCH] PNP: add a error handling in pnpacpi_init() Haoxiang Li
2025-12-18 11:33 ` Greg KH
2025-12-18 12:24   ` Haoxiang Li
2025-12-18 12:40     ` Greg KH
2025-12-18 13:07       ` Haoxiang Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox