From: Kaushlendra Kumar Date: Thu, 25 Sep 2025 05:41:29 +0000 (+0530) Subject: firmware_loader: Only call cancel when upload is active X-Git-Tag: v6.19-rc1~90^2~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe6193a3187a1a7482ccfbc904bc527e7730a36c;p=thirdparty%2Flinux.git firmware_loader: Only call cancel when upload is active The cancel_store() function currently calls the firmware upload cancel operation even when no upload is in progress (i.e., when progress is FW_UPLOAD_PROG_IDLE). Update cancel_store() to only invoke the cancel operation when an upload is active. If the upload is idle, return -ENODEV without calling cancel. This change improves safety and correctness by ensuring driver operations are only called in valid states. Signed-off-by: Kaushlendra Kumar Link: https://patch.msgid.link/20250925054129.2199157-1-kaushlendra.kumar@intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/firmware_loader/sysfs_upload.c b/drivers/base/firmware_loader/sysfs_upload.c index 829270067d163..c3797b93c5f5a 100644 --- a/drivers/base/firmware_loader/sysfs_upload.c +++ b/drivers/base/firmware_loader/sysfs_upload.c @@ -100,8 +100,10 @@ static ssize_t cancel_store(struct device *dev, struct device_attribute *attr, return -EINVAL; mutex_lock(&fwlp->lock); - if (fwlp->progress == FW_UPLOAD_PROG_IDLE) - ret = -ENODEV; + if (fwlp->progress == FW_UPLOAD_PROG_IDLE) { + mutex_unlock(&fwlp->lock); + return -ENODEV; + } fwlp->ops->cancel(fwlp->fw_upload); mutex_unlock(&fwlp->lock);