Print this page
10091 smatch fixes for ahci.c


6152 
6153         (void) snprintf(taskq_name + strlen(taskq_name),
6154             sizeof (taskq_name) - strlen(taskq_name),
6155             "_port%d", port);
6156 
6157         /* Create the taskq for the port */
6158         if ((ahci_portp->ahciport_event_taskq = ddi_taskq_create(dip,
6159             taskq_name, 2, TASKQ_DEFAULTPRI, 0)) == NULL) {
6160                 cmn_err(CE_WARN, "!ahci%d: ddi_taskq_create failed for event "
6161                     "handle", ddi_get_instance(ahci_ctlp->ahcictl_dip));
6162                 goto err_case3;
6163         }
6164 
6165         /* Allocate the argument for the taskq */
6166         ahci_portp->ahciport_event_args =
6167             kmem_zalloc(sizeof (ahci_event_arg_t), KM_SLEEP);
6168 
6169         ahci_portp->ahciport_event_args->ahciea_addrp =
6170             kmem_zalloc(sizeof (ahci_addr_t), KM_SLEEP);
6171 
6172         if (ahci_portp->ahciport_event_args == NULL)
6173                 goto err_case4;
6174 
6175         /* Initialize the done queue */
6176         ahci_portp->ahciport_doneq = NULL;
6177         ahci_portp->ahciport_doneqtail = &ahci_portp->ahciport_doneq;
6178         ahci_portp->ahciport_doneq_len = 0;
6179 
6180         mutex_exit(&ahci_portp->ahciport_mutex);
6181 
6182         return (AHCI_SUCCESS);
6183 
6184 err_case4:
6185         ddi_taskq_destroy(ahci_portp->ahciport_event_taskq);
6186 
6187 err_case3:
6188         ahci_dealloc_cmd_list(ahci_ctlp, ahci_portp);
6189 
6190 err_case2:
6191         ahci_dealloc_rcvd_fis(ahci_portp);
6192 
6193 err_case1:
6194         mutex_exit(&ahci_portp->ahciport_mutex);
6195         mutex_destroy(&ahci_portp->ahciport_mutex);
6196         cv_destroy(&ahci_portp->ahciport_cv);
6197 
6198         kmem_free(ahci_portp, sizeof (ahci_port_t));
6199 
6200         return (AHCI_FAILURE);
6201 }
6202 
6203 /*
6204  * Reverse of ahci_alloc_port_state().
6205  */
6206 static void




6152 
6153         (void) snprintf(taskq_name + strlen(taskq_name),
6154             sizeof (taskq_name) - strlen(taskq_name),
6155             "_port%d", port);
6156 
6157         /* Create the taskq for the port */
6158         if ((ahci_portp->ahciport_event_taskq = ddi_taskq_create(dip,
6159             taskq_name, 2, TASKQ_DEFAULTPRI, 0)) == NULL) {
6160                 cmn_err(CE_WARN, "!ahci%d: ddi_taskq_create failed for event "
6161                     "handle", ddi_get_instance(ahci_ctlp->ahcictl_dip));
6162                 goto err_case3;
6163         }
6164 
6165         /* Allocate the argument for the taskq */
6166         ahci_portp->ahciport_event_args =
6167             kmem_zalloc(sizeof (ahci_event_arg_t), KM_SLEEP);
6168 
6169         ahci_portp->ahciport_event_args->ahciea_addrp =
6170             kmem_zalloc(sizeof (ahci_addr_t), KM_SLEEP);
6171 



6172         /* Initialize the done queue */
6173         ahci_portp->ahciport_doneq = NULL;
6174         ahci_portp->ahciport_doneqtail = &ahci_portp->ahciport_doneq;
6175         ahci_portp->ahciport_doneq_len = 0;
6176 
6177         mutex_exit(&ahci_portp->ahciport_mutex);
6178 
6179         return (AHCI_SUCCESS);
6180 



6181 err_case3:
6182         ahci_dealloc_cmd_list(ahci_ctlp, ahci_portp);
6183 
6184 err_case2:
6185         ahci_dealloc_rcvd_fis(ahci_portp);
6186 
6187 err_case1:
6188         mutex_exit(&ahci_portp->ahciport_mutex);
6189         mutex_destroy(&ahci_portp->ahciport_mutex);
6190         cv_destroy(&ahci_portp->ahciport_cv);
6191 
6192         kmem_free(ahci_portp, sizeof (ahci_port_t));
6193 
6194         return (AHCI_FAILURE);
6195 }
6196 
6197 /*
6198  * Reverse of ahci_alloc_port_state().
6199  */
6200 static void