Index: head/sys/dev/nvme/nvme.c =================================================================== --- head/sys/dev/nvme/nvme.c +++ head/sys/dev/nvme/nvme.c @@ -138,7 +138,8 @@ ctrlr->config_hook.ich_func = nvme_ctrlr_start_config_hook; ctrlr->config_hook.ich_arg = ctrlr; - config_intrhook_establish(&ctrlr->config_hook); + if (config_intrhook_establish(&ctrlr->config_hook) != 0) + return (ENOMEM); return (0); } Index: head/sys/dev/nvme/nvme_ctrlr.c =================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c +++ head/sys/dev/nvme/nvme_ctrlr.c @@ -1335,6 +1335,7 @@ struct nvme_get_nsid *gnsid = (struct nvme_get_nsid *)arg; strncpy(gnsid->cdev, device_get_nameunit(ctrlr->dev), sizeof(gnsid->cdev)); + gnsid->cdev[sizeof(gnsid->cdev) - 1] = '\0'; gnsid->nsid = 0; break; } @@ -1619,12 +1620,12 @@ goto fail; /* - * Now that we're reset the hardware, we can restart the controller. Any + * Now that we've reset the hardware, we can restart the controller. Any * I/O that was pending is requeued. Any admin commands are aborted with * an error. Once we've restarted, take the controller out of reset. */ nvme_ctrlr_start(ctrlr, true); - atomic_cmpset_32(&ctrlr->is_resetting, 1, 0); + (void)atomic_cmpset_32(&ctrlr->is_resetting, 1, 0); return (0); fail: @@ -1635,6 +1636,6 @@ */ nvme_printf(ctrlr, "Failed to reset on resume, failing.\n"); nvme_ctrlr_fail(ctrlr); - atomic_cmpset_32(&ctrlr->is_resetting, 1, 0); + (void)atomic_cmpset_32(&ctrlr->is_resetting, 1, 0); return (0); } Index: head/sys/dev/nvme/nvme_ns.c =================================================================== --- head/sys/dev/nvme/nvme_ns.c +++ head/sys/dev/nvme/nvme_ns.c @@ -87,6 +87,7 @@ struct nvme_get_nsid *gnsid = (struct nvme_get_nsid *)arg; strncpy(gnsid->cdev, device_get_nameunit(ctrlr->dev), sizeof(gnsid->cdev)); + gnsid->cdev[sizeof(gnsid->cdev) - 1] = '\0'; gnsid->nsid = ns->id; break; } Index: head/sys/dev/nvme/nvme_pci.c =================================================================== --- head/sys/dev/nvme/nvme_pci.c +++ head/sys/dev/nvme/nvme_pci.c @@ -243,11 +243,9 @@ return (ENOMEM); } - bus_setup_intr(ctrlr->dev, ctrlr->res, + if (bus_setup_intr(ctrlr->dev, ctrlr->res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, nvme_ctrlr_intx_handler, - ctrlr, &ctrlr->tag); - - if (ctrlr->tag == NULL) { + ctrlr, &ctrlr->tag) != 0) { nvme_printf(ctrlr, "unable to setup intx handler\n"); return (ENOMEM); } Index: head/sys/dev/nvme/nvme_qpair.c =================================================================== --- head/sys/dev/nvme/nvme_qpair.c +++ head/sys/dev/nvme/nvme_qpair.c @@ -671,9 +671,12 @@ qpair->res = bus_alloc_resource_any(ctrlr->dev, SYS_RES_IRQ, &qpair->rid, RF_ACTIVE); - bus_setup_intr(ctrlr->dev, qpair->res, + if (bus_setup_intr(ctrlr->dev, qpair->res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, - nvme_qpair_msix_handler, qpair, &qpair->tag); + nvme_qpair_msix_handler, qpair, &qpair->tag) != 0) { + nvme_printf(ctrlr, "unable to setup intx handler\n"); + goto out; + } if (qpair->id == 0) { bus_describe_intr(ctrlr->dev, qpair->res, qpair->tag, "admin"); Index: head/sys/dev/nvme/nvme_sysctl.c =================================================================== --- head/sys/dev/nvme/nvme_sysctl.c +++ head/sys/dev/nvme/nvme_sysctl.c @@ -146,16 +146,17 @@ nvme_sysctl_timeout_period(SYSCTL_HANDLER_ARGS) { struct nvme_controller *ctrlr = arg1; - uint32_t oldval = ctrlr->timeout_period; - int error = sysctl_handle_int(oidp, &ctrlr->timeout_period, 0, req); + uint32_t newval = ctrlr->timeout_period; + int error = sysctl_handle_int(oidp, &newval, 0, req); - if (error) + if (error || (req->newptr == NULL)) return (error); - if (ctrlr->timeout_period > NVME_MAX_TIMEOUT_PERIOD || - ctrlr->timeout_period < NVME_MIN_TIMEOUT_PERIOD) { - ctrlr->timeout_period = oldval; + if (newval > NVME_MAX_TIMEOUT_PERIOD || + newval < NVME_MIN_TIMEOUT_PERIOD) { return (EINVAL); + } else { + ctrlr->timeout_period = newval; } return (0); Index: head/sys/dev/nvme/nvme_test.c =================================================================== --- head/sys/dev/nvme/nvme_test.c +++ head/sys/dev/nvme/nvme_test.c @@ -100,7 +100,7 @@ idx = atomic_fetchadd_int(&io_test->td_idx, 1); dev = io_test->ns->cdev; - offset = idx * 2048 * nvme_ns_get_sector_size(io_test->ns); + offset = idx * 2048ULL * nvme_ns_get_sector_size(io_test->ns); while (1) { @@ -120,6 +120,8 @@ } else csw = dev->si_devsw; + if (csw == NULL) + panic("Unable to retrieve device switch"); mtx = mtx_pool_find(mtxpool_sleep, bio); mtx_lock(mtx); (*csw->d_strategy)(bio);