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

*** 19,29 **** * CDDL HEADER END */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. ! * Copyright (c) 2017, Joyent, Inc. * Copyright 2015 Garrett D'Amore <garrett@damore.org> */ /* * MAC Services Module --- 19,29 ---- * CDDL HEADER END */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. ! * Copyright 2019 Joyent, Inc. * Copyright 2015 Garrett D'Amore <garrett@damore.org> */ /* * MAC Services Module
*** 2285,2312 **** * Allocate a minor number. */ minor_t mac_minor_hold(boolean_t sleep) { ! minor_t minor; /* * 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); ! if (minor == 0) { atomic_dec_32(&minor_count); return (0); } ! return (minor); } /* * Release a previously allocated minor number. */ --- 2285,2310 ---- * Allocate a minor number. */ minor_t mac_minor_hold(boolean_t sleep) { ! id_t id; /* * Grab a value from the arena. */ atomic_inc_32(&minor_count); if (sleep) ! return ((uint_t)id_alloc(minor_ids)); ! if ((id = id_alloc_nosleep(minor_ids)) == -1) { atomic_dec_32(&minor_count); return (0); } ! return ((uint_t)id); } /* * Release a previously allocated minor number. */