char: misc: deallocate static minor in error path
BugLink: https://bugs.launchpad.net/bugs/2114239 commit 6d991f569c5ef6eaeadf1238df2c36e3975233ad upstream. 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: 6d04d2b554b1 ("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> (cherry picked from commit d43b3f646686070c6aaec068d8f53475571edac3 linux-6.6.y) [nwager: Follow-up fix from 6.6.83] Signed-off-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
26b8a800bb
commit
c5d2f77631
+1
-1
@@ -264,8 +264,8 @@ int misc_register(struct miscdevice *misc)
|
||||
device_create_with_groups(&misc_class, misc->parent, dev,
|
||||
misc, misc->groups, "%s", misc->name);
|
||||
if (IS_ERR(misc->this_device)) {
|
||||
misc_minor_free(misc->minor);
|
||||
if (is_dynamic) {
|
||||
misc_minor_free(misc->minor);
|
||||
misc->minor = MISC_DYNAMIC_MINOR;
|
||||
}
|
||||
err = PTR_ERR(misc->this_device);
|
||||
|
||||
Reference in New Issue
Block a user