]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Drivers: char: misc: 'misc_deregister()' changed the 'mutex_unlock' logic upon an...
authorElad Wexler <elad.wexler@gmail.com>
Sat, 14 Sep 2013 15:02:11 +0000 (18:02 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Sep 2013 15:53:23 +0000 (08:53 -0700)
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>
drivers/char/misc.c

index 190d4423653f6b99690967ba3602915eda5463fb..2f685f6eda4868195d9dcc3ac7d317e9cc2fc42a 100644 (file)
@@ -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;
                        }
                }
        }