[PATCH] PNP: add a put_device() in isapnp_init()

Haoxiang Li posted 1 patch 1 month, 3 weeks ago
drivers/pnp/isapnp/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] PNP: add a put_device() in isapnp_init()
Posted by Haoxiang Li 1 month, 3 weeks ago
if pnp_register_protocol() 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/isapnp/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 219f96f2aaaf..d6daab7ed59e 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -983,8 +983,10 @@ static int __init isapnp_init(void)
 		return -EBUSY;
 	}
 
-	if (pnp_register_protocol(&isapnp_protocol) < 0)
+	if (pnp_register_protocol(&isapnp_protocol) < 0) {
+		put_device(&isapnp_protocol.dev);
 		return -EBUSY;
+	}
 
 	/*
 	 *      Print a message. The existing ISAPnP code is hanging machines
-- 
2.25.1
Re: [PATCH] PNP: add a put_device() in isapnp_init()
Posted by Greg KH 1 month, 3 weeks ago
On Thu, Dec 18, 2025 at 04:36:46PM +0800, Haoxiang Li wrote:
> if pnp_register_protocol() 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/isapnp/core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
> index 219f96f2aaaf..d6daab7ed59e 100644
> --- a/drivers/pnp/isapnp/core.c
> +++ b/drivers/pnp/isapnp/core.c
> @@ -983,8 +983,10 @@ static int __init isapnp_init(void)
>  		return -EBUSY;
>  	}
>  
> -	if (pnp_register_protocol(&isapnp_protocol) < 0)
> +	if (pnp_register_protocol(&isapnp_protocol) < 0) {
> +		put_device(&isapnp_protocol.dev);

Same here, this feels very wrong.

How was this tested?

How was this found?

thanks,

greg k-h