Skip to content

Commit 6d991f5

Browse files
Thadeu Lima de Souza Cascardogregkh
authored andcommitted
char: misc: deallocate static minor in error path
When creating sysfs files fail, the allocated minor must be freed such that it can be later reused. That is specially harmful for static minor numbers, since those would always fail to register later on. Fixes: 6d04d2b ("misc: misc_minor_alloc to use ida for all dynamic/misc dynamic minors") Cc: stable <stable@kernel.org> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com> Link: https://lore.kernel.org/r/20250123123249.4081674-5-cascardo@igalia.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 038ef07 commit 6d991f5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/char/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ int misc_register(struct miscdevice *misc)
264264
device_create_with_groups(&misc_class, misc->parent, dev,
265265
misc, misc->groups, "%s", misc->name);
266266
if (IS_ERR(misc->this_device)) {
267+
misc_minor_free(misc->minor);
267268
if (is_dynamic) {
268-
misc_minor_free(misc->minor);
269269
misc->minor = MISC_DYNAMIC_MINOR;
270270
}
271271
err = PTR_ERR(misc->this_device);

0 commit comments

Comments
 (0)