From: Keith Busch Date: Thu, 15 Jun 2023 15:17:57 +0000 (-0700) Subject: nvme: forward port sysfs delete fix X-Git-Tag: for-6.5/block-2023-06-23~27^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1c606f7f056b266a84482d5522d35bbbbed062db;p=linux-2.6-block.git nvme: forward port sysfs delete fix We had a late fix that modified nvme_sysfs_delete() after the staging branch for the next merge window relocated the function to a new file. Port commit 2eb94dd56a4a4 ("nvme: do not let the user delete a ctrl before a complete") to the latest to avoid a potentially confusing merge conflict. Cc: Maurizio Lombardi Cc: Max Gurtovoy Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch --- diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c index 796e1d373b7c..45e91811f905 100644 --- a/drivers/nvme/host/sysfs.c +++ b/drivers/nvme/host/sysfs.c @@ -202,6 +202,9 @@ static ssize_t nvme_sysfs_delete(struct device *dev, { struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + if (!test_bit(NVME_CTRL_STARTED_ONCE, &ctrl->flags)) + return -EBUSY; + if (device_remove_file_self(dev, attr)) nvme_delete_ctrl_sync(ctrl); return count;