diff options
author | Elad Wexler <elad.wexler@gmail.com> | 2013-09-14 18:02:11 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 08:53:23 -0700 |
commit | 684116caa44d1642fcbd4d1d5b9cb975572cfa0b (patch) | |
tree | 422fad1cdcf2f61bcbc7538fff531aee48fa3a8a /drivers/char/misc.c | |
parent | bbf831dfe8538ef3797c9603b7897d4ad9ef9d4a (diff) | |
download | lwn-684116caa44d1642fcbd4d1d5b9cb975572cfa0b.tar.gz lwn-684116caa44d1642fcbd4d1d5b9cb975572cfa0b.zip |
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>
Diffstat (limited to 'drivers/char/misc.c')
-rw-r--r-- | drivers/char/misc.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 190d4423653f..2f685f6eda48 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -193,8 +193,8 @@ int misc_register(struct miscdevice * misc) if (misc->minor == MISC_DYNAMIC_MINOR) { int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS); if (i >= DYNAMIC_MINORS) { - mutex_unlock(&misc_mtx); - return -EBUSY; + err = -EBUSY; + goto out; } misc->minor = DYNAMIC_MINORS - i - 1; set_bit(i, misc_minors); @@ -203,8 +203,8 @@ int misc_register(struct miscdevice * misc) list_for_each_entry(c, &misc_list, list) { if (c->minor == misc->minor) { - mutex_unlock(&misc_mtx); - return -EBUSY; + err = -EBUSY; + goto out; } } } |