Re: [PATCH] PNP: add a error handling in pnpacpi_init()

From: Greg KH
Date: Thu Dec 18 2025 - 06:42:02 EST


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@xxxxxxxxxxxxxxx
> Signed-off-by: Haoxiang Li <lihaoxiang@xxxxxxxxxxxxxxxx>
> ---
> 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