ipmi: Remove all sysfs files on registration failure
PATCH 1/1 ipmi: Remove all sysfs files on registration failure
ipmi_add_smi() creates the nr_users and nr_msgs files before trying to create the maintenance_mode file. If that last creation fails, the error path removes only nr_users before dropping the final reference to the interface.
Remove nr_msgs as well so no sysfs attribute embedded in the freed interface remains registered.
--- drivers/char/ipmi/ipmi_msghandler.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/ipmi/ipmi_msghandler.c +1 -0
@@ -3740,6 +3740,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; }
Signature · 1 line
2.43.0
Corey Minyard
maintainerQuoted 7 lines · Yuho Choi
ipmi_add_smi()creates thenr_usersandnr_msgsfiles before trying to create themaintenance_modefile. If that last creation fails, the error path removes onlynr_usersbefore dropping the final reference to the interface.Remove
nr_msgsas well so no sysfs attribute embedded in the freed interface remains registered.
Thanks, this is queued for next release.
I've also copied stable for a backport to 6.18.
-corey
Quoted 22 lines
Fixes 627118470fcc ("ipmi: Add a maintenance mode sysfs file")Signed-off-by Yuho Choi <[email protected]>--- drivers/char/ipmi/ipmi_msghandler.c | 1 + 1 file changed, 1 insertion(+)drivers/char/ipmi/ipmi_msghandler.c +1
-0@@ -3740,6 +3740,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; }Signature · 1 line
2.43.0