Print this page
5047 don't use atomic_*_nv if you discard the return value

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/sctp/sctp_addr.c
          +++ new/usr/src/uts/common/inet/sctp/sctp_addr.c
↓ open down ↓ 129 lines elided ↑ open up ↑
 130  130                  rw_exit(&sctps->sctps_g_ills_lock);
 131  131                  return;
 132  132          }
 133  133          list_remove(&sctps->sctps_g_ipifs[hindex].sctp_ipif_list,
 134  134              sctp_ipif);
 135  135          sctps->sctps_g_ipifs[hindex].ipif_count--;
 136  136          sctps->sctps_g_ipifs_count--;
 137  137          rw_destroy(&sctp_ipif->sctp_ipif_lock);
 138  138          kmem_free(sctp_ipif, sizeof (sctp_ipif_t));
 139  139  
 140      -        (void) atomic_dec_32_nv(&sctp_ill->sctp_ill_ipifcnt);
      140 +        atomic_dec_32(&sctp_ill->sctp_ill_ipifcnt);
 141  141          if (rw_tryupgrade(&sctps->sctps_g_ills_lock) != 0) {
 142  142                  rw_downgrade(&sctps->sctps_g_ipifs_lock);
 143  143                  if (sctp_ill->sctp_ill_ipifcnt == 0 &&
 144  144                      sctp_ill->sctp_ill_state == SCTP_ILLS_CONDEMNED) {
 145  145                          list_remove(&sctps->sctps_g_ills[ill_index].
 146  146                              sctp_ill_list, (void *)sctp_ill);
 147  147                          sctps->sctps_g_ills[ill_index].ill_count--;
 148  148                          sctps->sctps_ills_count--;
 149  149                          kmem_free(sctp_ill->sctp_ill_name,
 150  150                              sctp_ill->sctp_ill_name_length);
↓ open down ↓ 726 lines elided ↑ open up ↑
 877  877                  ip1dbg(("sctp_move_ipif: error moving ipif %p from %p to %p\n",
 878  878                      (void *)ipif, (void *)f_ill, (void *)t_ill));
 879  879                  rw_exit(&sctps->sctps_g_ipifs_lock);
 880  880                  rw_exit(&sctps->sctps_g_ills_lock);
 881  881                  return;
 882  882          }
 883  883          rw_enter(&sctp_ipif->sctp_ipif_lock, RW_WRITER);
 884  884          ASSERT(sctp_ipif->sctp_ipif_ill == fsctp_ill);
 885  885          sctp_ipif->sctp_ipif_ill = tsctp_ill;
 886  886          rw_exit(&sctp_ipif->sctp_ipif_lock);
 887      -        (void) atomic_dec_32_nv(&fsctp_ill->sctp_ill_ipifcnt);
      887 +        atomic_dec_32(&fsctp_ill->sctp_ill_ipifcnt);
 888  888          atomic_inc_32(&tsctp_ill->sctp_ill_ipifcnt);
 889  889          rw_exit(&sctps->sctps_g_ipifs_lock);
 890  890          rw_exit(&sctps->sctps_g_ills_lock);
 891  891  }
 892  892  
 893  893  /*
 894  894   * Walk the list of SCTPs and find each that has oipif in it's saddr list, and
 895  895   * if so replace it with nipif.
 896  896   */
 897  897  void
↓ open down ↓ 192 lines elided ↑ open up ↑
1090 1090                              osctp_ipif->sctp_ipif_isv6);
1091 1091  
1092 1092                          ipif_list =
1093 1093                              &sctps->sctps_g_ipifs[ohindex].sctp_ipif_list;
1094 1094  
1095 1095                          list_remove(ipif_list, (void *)osctp_ipif);
1096 1096                          sctps->sctps_g_ipifs[ohindex].ipif_count--;
1097 1097                          sctps->sctps_g_ipifs_count--;
1098 1098                          rw_destroy(&osctp_ipif->sctp_ipif_lock);
1099 1099                          kmem_free(osctp_ipif, sizeof (sctp_ipif_t));
1100      -                        (void) atomic_dec_32_nv(&osctp_ill->sctp_ill_ipifcnt);
     1100 +                        atomic_dec_32(&osctp_ill->sctp_ill_ipifcnt);
1101 1101                  }
1102 1102          }
1103 1103  
1104 1104          sctp_ipif = kmem_zalloc(sizeof (sctp_ipif_t), KM_NOSLEEP);
1105 1105          /* Try again? */
1106 1106          if (sctp_ipif == NULL) {
1107 1107                  cmn_err(CE_WARN, "sctp_update_ipif_addr: error adding "
1108 1108                      "IPIF %p to SCTP's IPIF list", (void *)ipif);
1109 1109                  rw_exit(&sctps->sctps_g_ipifs_lock);
1110 1110                  rw_exit(&sctps->sctps_g_ills_lock);
↓ open down ↓ 91 lines elided ↑ open up ↑
1202 1202                          sctp_ipif->sctp_ipif_state = SCTP_IPIFS_CONDEMNED;
1203 1203                          rw_exit(&sctps->sctps_g_ipifs_lock);
1204 1204                          rw_exit(&sctps->sctps_g_ills_lock);
1205 1205                          return;
1206 1206                  }
1207 1207                  list_remove(ipif_list, (void *)sctp_ipif);
1208 1208                  sctps->sctps_g_ipifs[hindex].ipif_count--;
1209 1209                  sctps->sctps_g_ipifs_count--;
1210 1210                  rw_destroy(&sctp_ipif->sctp_ipif_lock);
1211 1211                  kmem_free(sctp_ipif, sizeof (sctp_ipif_t));
1212      -                (void) atomic_dec_32_nv(&sctp_ill->sctp_ill_ipifcnt);
     1212 +                atomic_dec_32(&sctp_ill->sctp_ill_ipifcnt);
1213 1213                  if (rw_tryupgrade(&sctps->sctps_g_ills_lock) != 0) {
1214 1214                          rw_downgrade(&sctps->sctps_g_ipifs_lock);
1215 1215                          if (sctp_ill->sctp_ill_ipifcnt == 0 &&
1216 1216                              sctp_ill->sctp_ill_state == SCTP_ILLS_CONDEMNED) {
1217 1217                                  list_remove(ill_list, (void *)sctp_ill);
1218 1218                                  sctps->sctps_ills_count--;
1219 1219                                  sctps->sctps_g_ills[ill_index].ill_count--;
1220 1220                                  kmem_free(sctp_ill->sctp_ill_name,
1221 1221                                      sctp_ill->sctp_ill_name_length);
1222 1222                                  kmem_free(sctp_ill, sizeof (sctp_ill_t));
↓ open down ↓ 799 lines elided ↑ open up ↑
2022 2022                  return;
2023 2023  
2024 2024          for (i = 0; i < SCTP_IPIF_HASH; i++) {
2025 2025                  sctp_ipif = list_tail(&sctps->sctps_g_ipifs[i].sctp_ipif_list);
2026 2026                  for (l = 0; l < sctps->sctps_g_ipifs[i].ipif_count; l++) {
2027 2027                          sctp_ill = sctp_ipif->sctp_ipif_ill;
2028 2028  
2029 2029                          list_remove(&sctps->sctps_g_ipifs[i].sctp_ipif_list,
2030 2030                              sctp_ipif);
2031 2031                          sctps->sctps_g_ipifs_count--;
2032      -                        (void) atomic_dec_32_nv(&sctp_ill->sctp_ill_ipifcnt);
     2032 +                        atomic_dec_32(&sctp_ill->sctp_ill_ipifcnt);
2033 2033                          kmem_free(sctp_ipif, sizeof (sctp_ipif_t));
2034 2034                          sctp_ipif =
2035 2035                              list_tail(&sctps->sctps_g_ipifs[i].sctp_ipif_list);
2036 2036                  }
2037 2037                  sctps->sctps_g_ipifs[i].ipif_count = 0;
2038 2038          }
2039 2039          ASSERT(sctps->sctps_g_ipifs_count == 0);
2040 2040  }
2041 2041  
2042 2042  
↓ open down ↓ 50 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX