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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/zone.c
          +++ new/usr/src/uts/common/os/zone.c
↓ open down ↓ 4393 lines elided ↑ open up ↑
4394 4394                  insert_label_hash = B_FALSE;
4395 4395          }
4396 4396  
4397 4397          /*
4398 4398           * Stop all lwps since that's what normally happens as part of fork().
4399 4399           * This needs to happen before we grab any locks to avoid deadlock
4400 4400           * (another lwp in the process could be waiting for the held lock).
4401 4401           */
4402 4402          if (curthread != pp->p_agenttp && !holdlwps(SHOLDFORK)) {
4403 4403                  zone_free(zone);
4404      -                if (rctls)
4405      -                        nvlist_free(rctls);
     4404 +                nvlist_free(rctls);
4406 4405                  return (zone_create_error(error, 0, extended_error));
4407 4406          }
4408 4407  
4409 4408          if (block_mounts(zone) == 0) {
4410 4409                  mutex_enter(&pp->p_lock);
4411 4410                  if (curthread != pp->p_agenttp)
4412 4411                          continuelwps(pp);
4413 4412                  mutex_exit(&pp->p_lock);
4414 4413                  zone_free(zone);
4415      -                if (rctls)
4416      -                        nvlist_free(rctls);
     4414 +                nvlist_free(rctls);
4417 4415                  return (zone_create_error(error, 0, extended_error));
4418 4416          }
4419 4417  
4420 4418          /*
4421 4419           * Set up credential for kernel access.  After this, any errors
4422 4420           * should go through the dance in errout rather than calling
4423 4421           * zone_free directly.
4424 4422           */
4425 4423          zone->zone_kcred = crdup(kcred);
4426 4424          crsetzone(zone->zone_kcred, zone);
↓ open down ↓ 124 lines elided ↑ open up ↑
4551 4549          mutex_exit(&pp->p_lock);
4552 4550  
4553 4551          /*
4554 4552           * Wait for zsched to finish initializing the zone.
4555 4553           */
4556 4554          zone_status_wait(zone, ZONE_IS_READY);
4557 4555          /*
4558 4556           * The zone is fully visible, so we can let mounts progress.
4559 4557           */
4560 4558          resume_mounts(zone);
4561      -        if (rctls)
4562      -                nvlist_free(rctls);
     4559 +        nvlist_free(rctls);
4563 4560  
4564 4561          return (zoneid);
4565 4562  
4566 4563  errout:
4567 4564          mutex_exit(&zonehash_lock);
4568 4565          /*
4569 4566           * Let the other lwps continue.
4570 4567           */
4571 4568          mutex_enter(&pp->p_lock);
4572 4569          if (curthread != pp->p_agenttp)
4573 4570                  continuelwps(pp);
4574 4571          mutex_exit(&pp->p_lock);
4575 4572  
4576 4573          resume_mounts(zone);
4577      -        if (rctls)
4578      -                nvlist_free(rctls);
     4574 +        nvlist_free(rctls);
4579 4575          /*
4580 4576           * There is currently one reference to the zone, a cred_ref from
4581 4577           * zone_kcred.  To free the zone, we call crfree, which will call
4582 4578           * zone_cred_rele, which will call zone_free.
4583 4579           */
4584 4580          ASSERT(zone->zone_cred_ref == 1);
4585 4581          ASSERT(zone->zone_kcred->cr_ref == 1);
4586 4582          ASSERT(zone->zone_ref == 0);
4587 4583          zkcr = zone->zone_kcred;
4588 4584          zone->zone_kcred = NULL;
↓ open down ↓ 2279 lines elided ↑ open up ↑
6868 6864          int err = 0;
6869 6865  
6870 6866          if ((zone = zone_find_by_id(zoneid)) == NULL)
6871 6867                  return (set_errno(EINVAL));
6872 6868  
6873 6869          mutex_enter(&zone->zone_lock);
6874 6870          if ((zdl = zone_find_dl(zone, linkid)) == NULL) {
6875 6871                  err = ENXIO;
6876 6872          } else {
6877 6873                  list_remove(&zone->zone_dl_list, zdl);
6878      -                if (zdl->zdl_net != NULL)
6879      -                        nvlist_free(zdl->zdl_net);
     6874 +                nvlist_free(zdl->zdl_net);
6880 6875                  kmem_free(zdl, sizeof (zone_dl_t));
6881 6876          }
6882 6877          mutex_exit(&zone->zone_lock);
6883 6878          zone_rele(zone);
6884 6879          return (err == 0 ? 0 : set_errno(err));
6885 6880  }
6886 6881  
6887 6882  /*
6888 6883   * Using the zoneidp as ALL_ZONES, we can lookup which zone has been assigned
6889 6884   * the linkid.  Otherwise we just check if the specified zoneidp has been
↓ open down ↓ 285 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX