[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220614160126.1739982-1-zhi.song@bytedance.com>
Date: Wed, 15 Jun 2022 00:01:26 +0800
From: Zhi Song <zhi.song@...edance.com>
To: vilhelm.gray@...il.com, gregkh@...uxfoundation.org,
rafael@...nel.org
Cc: linux-kernel@...r.kernel.org, Zhi Song <zhi.song@...edance.com>
Subject: [PATCH] isa: put_device after failing to device_register
device_register() is used to register a device with the system.
We need to call put_device() to give up the reference initialized
in device_register() when it returns an error and this will clean
up correctly.
Signed-off-by: Zhi Song <zhi.song@...edance.com>
---
drivers/base/isa.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/base/isa.c b/drivers/base/isa.c
index 55e3ee2da98f..cf88f3d77b7d 100644
--- a/drivers/base/isa.c
+++ b/drivers/base/isa.c
@@ -173,8 +173,10 @@ static int __init isa_bus_init(void)
error = bus_register(&isa_bus_type);
if (!error) {
error = device_register(&isa_bus);
- if (error)
+ if (error) {
+ put_device(&isa_bus);
bus_unregister(&isa_bus_type);
+ }
}
return error;
}
--
2.30.2
Powered by blists - more mailing lists