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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/mac/mac.c
          +++ new/usr/src/uts/common/io/mac/mac.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright (c) 2017, Joyent, Inc.
       24 + * Copyright 2019 Joyent, Inc.
  25   25   * Copyright 2015 Garrett D'Amore <garrett@damore.org>
  26   26   */
  27   27  
  28   28  /*
  29   29   * MAC Services Module
  30   30   *
  31   31   * The GLDv3 framework locking -  The MAC layer
  32   32   * --------------------------------------------
  33   33   *
  34   34   * The MAC layer is central to the GLD framework and can provide the locking
↓ open down ↓ 2245 lines elided ↑ open up ↑
2280 2280          mac_rx_client_restart((mac_client_handle_t)mcip);
2281 2281          mac_tx_client_restart((mac_client_handle_t)mcip);
2282 2282  }
2283 2283  
2284 2284  /*
2285 2285   * Allocate a minor number.
2286 2286   */
2287 2287  minor_t
2288 2288  mac_minor_hold(boolean_t sleep)
2289 2289  {
2290      -        minor_t minor;
     2290 +        id_t id;
2291 2291  
2292 2292          /*
2293 2293           * Grab a value from the arena.
2294 2294           */
2295 2295          atomic_inc_32(&minor_count);
2296 2296  
2297 2297          if (sleep)
2298      -                minor = (uint_t)id_alloc(minor_ids);
2299      -        else
2300      -                minor = (uint_t)id_alloc_nosleep(minor_ids);
     2298 +                return ((uint_t)id_alloc(minor_ids));
2301 2299  
2302      -        if (minor == 0) {
     2300 +        if ((id = id_alloc_nosleep(minor_ids)) == -1) {
2303 2301                  atomic_dec_32(&minor_count);
2304 2302                  return (0);
2305 2303          }
2306 2304  
2307      -        return (minor);
     2305 +        return ((uint_t)id);
2308 2306  }
2309 2307  
2310 2308  /*
2311 2309   * Release a previously allocated minor number.
2312 2310   */
2313 2311  void
2314 2312  mac_minor_rele(minor_t minor)
2315 2313  {
2316 2314          /*
2317 2315           * Return the value to the arena.
↓ open down ↓ 5939 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX