diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c --- a/drivers/nvme/host/sysfs.c +++ b/drivers/nvme/host/sysfs.c @@ -17,6 +17,14 @@ static ssize_t nvme_sysfs_reset(struct device *dev, { struct nvme_ctrl *ctrl = dev_get_drvdata(dev); int ret; + /* + * nvme_add_ctrl() publishes this attribute before some transports have + * finished creating their queues. Do not let userspace reset a controller + * while it is still being initialized. + */ + if (nvme_ctrl_state(ctrl) != NVME_CTRL_LIVE) + return -EBUSY; + ret = nvme_reset_ctrl_sync(ctrl); if (ret < 0) return ret;