Skip to contentSkip to conversation

firmware_loader: Only call cancel when upload is active

PATCH New Kaushlendra Kumar 1 participant 1 message Sep 25, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/base/firmware_loader/sysfs_upload.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/base/firmware_loader/sysfs_upload.c +4 -2
index 829270067d16..c3797b93c5f5 100644
@@ -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);
Signature · 1 line
2.34.1