Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/klpd.c
          +++ new/usr/src/uts/common/os/klpd.c
↓ open down ↓ 79 lines elided ↑ open up ↑
  80   80  
  81   81  static credklpd_t *crklpd_alloc(void);
  82   82  
  83   83  void crklpd_setreg(credklpd_t *, klpd_reg_t *);
  84   84  
  85   85  extern size_t max_vnode_path;
  86   86  
  87   87  void
  88   88  klpd_rele(klpd_reg_t *p)
  89   89  {
  90      -        if (atomic_add_32_nv(&p->klpd_ref, -1) == 0) {
       90 +        if (atomic_dec_32_nv(&p->klpd_ref) == 0) {
  91   91                  if (p->klpd_refp != NULL)
  92   92                          klpd_unlink(p);
  93   93                  if (p->klpd_cred != NULL)
  94   94                          crfree(p->klpd_cred);
  95   95                  door_ki_rele(p->klpd_door);
  96   96                  kmem_free(p, sizeof (*p));
  97   97          }
  98   98  }
  99   99  
 100  100  /*
↓ open down ↓ 8 lines elided ↑ open up ↑
 109  109          klpd_reg_t *r = p->klpd_next;
 110  110  
 111  111          klpd_rele(p);
 112  112          return (r);
 113  113  }
 114  114  
 115  115  
 116  116  static void
 117  117  klpd_hold(klpd_reg_t *p)
 118  118  {
 119      -        atomic_add_32(&p->klpd_ref, 1);
      119 +        atomic_inc_32(&p->klpd_ref);
 120  120  }
 121  121  
 122  122  /*
 123  123   * Remove registration from where it is registered.  Returns next in list.
 124  124   */
 125  125  static void
 126  126  klpd_unlink(klpd_reg_t *p)
 127  127  {
 128  128          ASSERT(p->klpd_refp == NULL || *p->klpd_refp == p);
 129  129  
↓ open down ↓ 213 lines elided ↑ open up ↑
 343  343  
 344  344          /*
 345  345           * These locks must not be held when this code is called;
 346  346           * callbacks to userland with these locks held will result
 347  347           * in issues.  That said, the code at the call sides was
 348  348           * restructured not to call with any of the locks held and
 349  349           * no policies operate by default on most processes.
 350  350           */
 351  351          if (mutex_owned(&pidlock) || mutex_owned(&curproc->p_lock) ||
 352  352              mutex_owned(&curproc->p_crlock)) {
 353      -                atomic_add_32(&klpd_bad_locks, 1);
      353 +                atomic_inc_32(&klpd_bad_locks);
 354  354                  return (-1);
 355  355          }
 356  356  
 357  357          /*
 358  358           * Enforce the limit set for the call process (still).
 359  359           */
 360  360          if (!priv_issubset(req, &CR_LPRIV(cr)))
 361  361                  return (-1);
 362  362  
 363  363          /* Try 1: get the credential specific klpd */
↓ open down ↓ 303 lines elided ↑ open up ↑
 667  667          door_ki_rele(dh);
 668  668  
 669  669          if (res != 0)
 670  670                  return (set_errno(res));
 671  671          return (0);
 672  672  }
 673  673  
 674  674  void
 675  675  crklpd_hold(credklpd_t *crkpd)
 676  676  {
 677      -        atomic_add_32(&crkpd->crkl_ref, 1);
      677 +        atomic_inc_32(&crkpd->crkl_ref);
 678  678  }
 679  679  
 680  680  void
 681  681  crklpd_rele(credklpd_t *crkpd)
 682  682  {
 683      -        if (atomic_add_32_nv(&crkpd->crkl_ref, -1) == 0) {
      683 +        if (atomic_dec_32_nv(&crkpd->crkl_ref) == 0) {
 684  684                  if (crkpd->crkl_reg != NULL)
 685  685                          klpd_rele(crkpd->crkl_reg);
 686  686                  mutex_destroy(&crkpd->crkl_lock);
 687  687                  kmem_free(crkpd, sizeof (*crkpd));
 688  688          }
 689  689  }
 690  690  
 691  691  static credklpd_t *
 692  692  crklpd_alloc(void)
 693  693  {
↓ open down ↓ 453 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX