* [PATCH] ipmi: Fix sysfs file leak on maintenance_mode creation failure
@ 2026-03-27 13:40 Felix Gu
2026-03-28 18:40 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-03-27 13:40 UTC (permalink / raw)
To: Corey Minyard; +Cc: openipmi-developer, linux-kernel, Felix Gu
When device_create_file() for maintenance_mode_devattr fails, the error
handler only removes nr_users_devattr but forgets to remove
nr_msgs_devattr, causing a sysfs file leak.
Fixes: 627118470fcc ("ipmi: Add a maintenance mode sysfs file")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/char/ipmi/ipmi_msghandler.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 869ac87a4b6a..f59db5df69da 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -3734,6 +3734,7 @@ int ipmi_add_smi(struct module *owner,
sysfs_attr_init(&intf->maintenance_mode_devattr.attr);
rv = device_create_file(intf->si_dev, &intf->maintenance_mode_devattr);
if (rv) {
+ device_remove_file(intf->si_dev, &intf->nr_msgs_devattr);
device_remove_file(intf->si_dev, &intf->nr_users_devattr);
goto out_err_bmc_reg;
}
---
base-commit: 66ba480978ce390e631e870b740a3406e3eb6b01
change-id: 20260327-ipmi-4851eac6305f
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ipmi: Fix sysfs file leak on maintenance_mode creation failure
2026-03-27 13:40 [PATCH] ipmi: Fix sysfs file leak on maintenance_mode creation failure Felix Gu
@ 2026-03-28 18:40 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2026-03-28 18:40 UTC (permalink / raw)
To: Felix Gu, openipmi-developer, Corey Minyard; +Cc: LKML
…
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -3734,6 +3734,7 @@ int ipmi_add_smi(struct module *owner,
> sysfs_attr_init(&intf->maintenance_mode_devattr.attr);
> rv = device_create_file(intf->si_dev, &intf->maintenance_mode_devattr);
> if (rv) {
> + device_remove_file(intf->si_dev, &intf->nr_msgs_devattr);
> device_remove_file(intf->si_dev, &intf->nr_users_devattr);
> goto out_err_bmc_reg;
> }
How do you think about to avoid a bit of duplicate source code here?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.0-rc5#n526
Regards,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-28 18:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-27 13:40 [PATCH] ipmi: Fix sysfs file leak on maintenance_mode creation failure Felix Gu
2026-03-28 18:40 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®