Print this page
6659 nvlist_free(NULL) is a no-op


1141                  * If no asru specified, get it from topo
1142                  */
1143                 if (nvlist_lookup_nvlist(nvlp[i], FM_FAULT_ASRU, &asru) != 0 &&
1144                     rsrc && topo_fmri_asru(thp, rsrc, &asru, &err) == 0)
1145                         (void) nvlist_add_nvlist(flt_copy, FM_FAULT_ASRU, asru);
1146                 /*
1147                  * If no location specified, get it from topo
1148                  */
1149                 if (nvlist_lookup_string(nvlp[i], FM_FAULT_LOCATION,
1150                     &loc) != 0) {
1151                         if (fru && topo_fmri_label(thp, fru, &loc, &err) == 0)
1152                                 (void) nvlist_add_string(flt_copy,
1153                                     FM_FAULT_LOCATION, loc);
1154                         else if (rsrc && topo_fmri_label(thp, rsrc, &loc,
1155                             &err) == 0)
1156                                 (void) nvlist_add_string(flt_copy,
1157                                     FM_FAULT_LOCATION, loc);
1158                         if (loc)
1159                                 topo_hdl_strfree(thp, loc);
1160                 }
1161                 if (fru)
1162                         nvlist_free(fru);
1163                 if (asru)
1164                         nvlist_free(asru);
1165                 if (rsrc)
1166                         nvlist_free(rsrc);
1167                 fmd_fmri_topo_rele(thp);
1168                 fmd_case_insert_suspect(cp, flt_copy);
1169         }
1170 
1171         /*
1172          * copy diag_time if present
1173          */
1174         if (nvlist_lookup_int64_array(nvl, FM_SUSPECT_DIAG_TIME, &diag_time,
1175             &nelem2) == 0 && nelem2 >= 2)
1176                 fmd_case_settime(cp, diag_time[0], diag_time[1]);
1177 
1178         /*
1179          * copy DE fmri if present
1180          */
1181         if (nvlist_lookup_nvlist(nvl, FM_SUSPECT_DE, &de_fmri) == 0) {
1182                 (void) nvlist_xdup(de_fmri, &de_fmri_dup, &fmd.d_nva);
1183                 fmd_case_set_de_fmri(cp, de_fmri_dup);
1184         }
1185 


1310          * there aren't any, then just drop the event.
1311          */
1312         if (got_hc_rsrc == 0 && got_hc_asru == 0 &&
1313             (xip->xi_flags & FMD_XPRT_HCONLY)) {
1314                 if (nelem > 0) {
1315                         fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
1316                         fmd_free(diag_asru, sizeof (uint8_t) * nelem);
1317                         fmd_free(asrua, sizeof (nvlist_t *) * nelem);
1318                 }
1319                 return;
1320         }
1321 
1322         /*
1323          * If we're set up only to report locally present hc-scheme
1324          * faults, and there aren't any, then just drop the event.
1325          */
1326         if (got_present_rsrc == 0 &&
1327             (xip->xi_flags & FMD_XPRT_HC_PRESENT_ONLY)) {
1328                 if (nelem > 0) {
1329                         for (i = 0; i < nelem; i++)
1330                                 if (asrua[i])
1331                                         nvlist_free(asrua[i]);
1332                         fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
1333                         fmd_free(diag_asru, sizeof (uint8_t) * nelem);
1334                         fmd_free(asrua, sizeof (nvlist_t *) * nelem);
1335                 }
1336                 return;
1337         }
1338 
1339         /*
1340          * If fmd_case_recreate() returns NULL, UUID is already known.
1341          */
1342         fmd_module_lock(xip->xi_queue->eq_mod);
1343         if ((cp = fmd_case_recreate(xip->xi_queue->eq_mod, xp,
1344             FMD_CASE_UNSOLVED, uuid, code)) == NULL) {
1345                 if (nelem > 0) {
1346                         for (i = 0; i < nelem; i++)
1347                                 if (asrua[i])
1348                                         nvlist_free(asrua[i]);
1349                         fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
1350                         fmd_free(diag_asru, sizeof (uint8_t) * nelem);
1351                         fmd_free(asrua, sizeof (nvlist_t *) * nelem);
1352                 }
1353                 fmd_module_unlock(xip->xi_queue->eq_mod);
1354                 return;
1355         }
1356 
1357         cip = (fmd_case_impl_t *)cp;
1358         cip->ci_diag_asru = diag_asru;
1359         cip->ci_proxy_asru = proxy_asru;
1360         for (i = 0; i < nelem; i++) {
1361                 (void) nvlist_xdup(nvlp[i], &flt_copy, &fmd.d_nva);
1362                 if (proxy_asru[i] != FMD_PROXY_ASRU_NOT_NEEDED) {
1363                         /*
1364                          * Copy suspects, but remove/replace asru first. Also if
1365                          * the original asru was hc-scheme use that as resource.
1366                          */
1367                         if (proxy_asru[i] == FMD_PROXY_ASRU_FROM_ASRU) {




1141                  * If no asru specified, get it from topo
1142                  */
1143                 if (nvlist_lookup_nvlist(nvlp[i], FM_FAULT_ASRU, &asru) != 0 &&
1144                     rsrc && topo_fmri_asru(thp, rsrc, &asru, &err) == 0)
1145                         (void) nvlist_add_nvlist(flt_copy, FM_FAULT_ASRU, asru);
1146                 /*
1147                  * If no location specified, get it from topo
1148                  */
1149                 if (nvlist_lookup_string(nvlp[i], FM_FAULT_LOCATION,
1150                     &loc) != 0) {
1151                         if (fru && topo_fmri_label(thp, fru, &loc, &err) == 0)
1152                                 (void) nvlist_add_string(flt_copy,
1153                                     FM_FAULT_LOCATION, loc);
1154                         else if (rsrc && topo_fmri_label(thp, rsrc, &loc,
1155                             &err) == 0)
1156                                 (void) nvlist_add_string(flt_copy,
1157                                     FM_FAULT_LOCATION, loc);
1158                         if (loc)
1159                                 topo_hdl_strfree(thp, loc);
1160                 }

1161                 nvlist_free(fru);

1162                 nvlist_free(asru);

1163                 nvlist_free(rsrc);
1164                 fmd_fmri_topo_rele(thp);
1165                 fmd_case_insert_suspect(cp, flt_copy);
1166         }
1167 
1168         /*
1169          * copy diag_time if present
1170          */
1171         if (nvlist_lookup_int64_array(nvl, FM_SUSPECT_DIAG_TIME, &diag_time,
1172             &nelem2) == 0 && nelem2 >= 2)
1173                 fmd_case_settime(cp, diag_time[0], diag_time[1]);
1174 
1175         /*
1176          * copy DE fmri if present
1177          */
1178         if (nvlist_lookup_nvlist(nvl, FM_SUSPECT_DE, &de_fmri) == 0) {
1179                 (void) nvlist_xdup(de_fmri, &de_fmri_dup, &fmd.d_nva);
1180                 fmd_case_set_de_fmri(cp, de_fmri_dup);
1181         }
1182 


1307          * there aren't any, then just drop the event.
1308          */
1309         if (got_hc_rsrc == 0 && got_hc_asru == 0 &&
1310             (xip->xi_flags & FMD_XPRT_HCONLY)) {
1311                 if (nelem > 0) {
1312                         fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
1313                         fmd_free(diag_asru, sizeof (uint8_t) * nelem);
1314                         fmd_free(asrua, sizeof (nvlist_t *) * nelem);
1315                 }
1316                 return;
1317         }
1318 
1319         /*
1320          * If we're set up only to report locally present hc-scheme
1321          * faults, and there aren't any, then just drop the event.
1322          */
1323         if (got_present_rsrc == 0 &&
1324             (xip->xi_flags & FMD_XPRT_HC_PRESENT_ONLY)) {
1325                 if (nelem > 0) {
1326                         for (i = 0; i < nelem; i++)

1327                                 nvlist_free(asrua[i]);
1328                         fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
1329                         fmd_free(diag_asru, sizeof (uint8_t) * nelem);
1330                         fmd_free(asrua, sizeof (nvlist_t *) * nelem);
1331                 }
1332                 return;
1333         }
1334 
1335         /*
1336          * If fmd_case_recreate() returns NULL, UUID is already known.
1337          */
1338         fmd_module_lock(xip->xi_queue->eq_mod);
1339         if ((cp = fmd_case_recreate(xip->xi_queue->eq_mod, xp,
1340             FMD_CASE_UNSOLVED, uuid, code)) == NULL) {
1341                 if (nelem > 0) {
1342                         for (i = 0; i < nelem; i++)

1343                                 nvlist_free(asrua[i]);
1344                         fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
1345                         fmd_free(diag_asru, sizeof (uint8_t) * nelem);
1346                         fmd_free(asrua, sizeof (nvlist_t *) * nelem);
1347                 }
1348                 fmd_module_unlock(xip->xi_queue->eq_mod);
1349                 return;
1350         }
1351 
1352         cip = (fmd_case_impl_t *)cp;
1353         cip->ci_diag_asru = diag_asru;
1354         cip->ci_proxy_asru = proxy_asru;
1355         for (i = 0; i < nelem; i++) {
1356                 (void) nvlist_xdup(nvlp[i], &flt_copy, &fmd.d_nva);
1357                 if (proxy_asru[i] != FMD_PROXY_ASRU_NOT_NEEDED) {
1358                         /*
1359                          * Copy suspects, but remove/replace asru first. Also if
1360                          * the original asru was hc-scheme use that as resource.
1361                          */
1362                         if (proxy_asru[i] == FMD_PROXY_ASRU_FROM_ASRU) {