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

* Re: [PATCH] PNP: add a error handling in pnpacpi_init()
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2025-12-18 11:33 UTC (permalink / raw)
  To: Haoxiang Li; +Cc: rafael, lenb, linux-acpi, linux-kernel, stable

On Thu, Dec 18, 2025 at 04:29:03PM +0800, Haoxiang Li wrote:
> 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);

Again, this looks really wrong.

What tool are you all using to "find" these issues?  Why aren't you
properly documenting it?

thanks,

greg k-h

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

* Re: [PATCH] PNP: add a error handling in pnpacpi_init()
  2025-12-18 11:33 ` Greg KH
@ 2025-12-18 12:24   ` Haoxiang Li
  2025-12-18 12:40     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Haoxiang Li @ 2025-12-18 12:24 UTC (permalink / raw)
  To: gregkh; +Cc: lenb, lihaoxiang, linux-acpi, linux-kernel, rafael, stable

On Thu, 18 Dec 2025 12:33:05 +0100, Greg KH Wrote:
> What tool are you all using to "find" these issues?  Why aren't you
> properly documenting it?

Sorry for the inconvenience. I found these through manual code review.
I realize I completely overlooked the static structure. I am sorry for
my lack of thoroughness again.
I will document how the issue was identified later.

Thanks,
Haoxiang Li


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

* Re: [PATCH] PNP: add a error handling in pnpacpi_init()
  2025-12-18 12:24   ` Haoxiang Li
@ 2025-12-18 12:40     ` Greg KH
  2025-12-18 13:07       ` Haoxiang Li
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2025-12-18 12:40 UTC (permalink / raw)
  To: Haoxiang Li; +Cc: lenb, linux-acpi, linux-kernel, rafael, stable

On Thu, Dec 18, 2025 at 08:24:22PM +0800, Haoxiang Li wrote:
> On Thu, 18 Dec 2025 12:33:05 +0100, Greg KH Wrote:
> > What tool are you all using to "find" these issues?  Why aren't you
> > properly documenting it?
> 
> Sorry for the inconvenience. I found these through manual code review.

Manually?  Really?  Why are you manually reviewing pnp code?  Do you
have this hardware?  Why not focus on code for hardware you have and can
test the fix for?

> I will document how the issue was identified later.

It should be in the changelog text, as is required.

thanks,

greg k-h

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

* Re: [PATCH] PNP: add a error handling in pnpacpi_init()
  2025-12-18 12:40     ` Greg KH
@ 2025-12-18 13:07       ` Haoxiang Li
  0 siblings, 0 replies; 5+ messages in thread
From: Haoxiang Li @ 2025-12-18 13:07 UTC (permalink / raw)
  To: gregkh; +Cc: lenb, lihaoxiang, linux-acpi, linux-kernel, rafael, stable

On Thu, 18 Dec 2025 13:40:09 +0100, Greg KH Wrote:
> Manually?  Really?  Why are you manually reviewing pnp code?  Do you
> have this hardware?  Why not focus on code for hardware you have and can
> test the fix for?

I apologize for the confusion. I did a targeted search for device_register()
and check their error handling. And Thanks for your guidance and patience!

> It should be in the changelog text, as is required.

Copy that. I will follow the rule.

Thanks,
Haoxiang Li


^ permalink raw reply	[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