Drivers: char: misc: 'misc_deregister()' changed the 'mutex_unlock' logic upon an error
This change improves code readability & is less error-prone. For example: case adding more error paths one should remember to call 'mutex_unlock' Signed-off-by: Elad Wexler <elad.wexler@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bbf831dfe8
commit
684116caa4
@ -193,8 +193,8 @@ int misc_register(struct miscdevice * misc)
|
|||||||
if (misc->minor == MISC_DYNAMIC_MINOR) {
|
if (misc->minor == MISC_DYNAMIC_MINOR) {
|
||||||
int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
|
int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
|
||||||
if (i >= DYNAMIC_MINORS) {
|
if (i >= DYNAMIC_MINORS) {
|
||||||
mutex_unlock(&misc_mtx);
|
err = -EBUSY;
|
||||||
return -EBUSY;
|
goto out;
|
||||||
}
|
}
|
||||||
misc->minor = DYNAMIC_MINORS - i - 1;
|
misc->minor = DYNAMIC_MINORS - i - 1;
|
||||||
set_bit(i, misc_minors);
|
set_bit(i, misc_minors);
|
||||||
@ -203,8 +203,8 @@ int misc_register(struct miscdevice * misc)
|
|||||||
|
|
||||||
list_for_each_entry(c, &misc_list, list) {
|
list_for_each_entry(c, &misc_list, list) {
|
||||||
if (c->minor == misc->minor) {
|
if (c->minor == misc->minor) {
|
||||||
mutex_unlock(&misc_mtx);
|
err = -EBUSY;
|
||||||
return -EBUSY;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user