Print this page
11929 mac_minor_hold() gets id_alloc_nosleep() wrong

@@ -19,11 +19,11 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2017, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
  * Copyright 2015 Garrett D'Amore <garrett@damore.org>
  */
 
 /*
  * MAC Services Module

@@ -2285,28 +2285,26 @@
  * Allocate a minor number.
  */
 minor_t
 mac_minor_hold(boolean_t sleep)
 {
-        minor_t minor;
+        id_t id;
 
         /*
          * Grab a value from the arena.
          */
         atomic_inc_32(&minor_count);
 
         if (sleep)
-                minor = (uint_t)id_alloc(minor_ids);
-        else
-                minor = (uint_t)id_alloc_nosleep(minor_ids);
+                return ((uint_t)id_alloc(minor_ids));
 
-        if (minor == 0) {
+        if ((id = id_alloc_nosleep(minor_ids)) == -1) {
                 atomic_dec_32(&minor_count);
                 return (0);
         }
 
-        return (minor);
+        return ((uint_t)id);
 }
 
 /*
  * Release a previously allocated minor number.
  */