Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <kaushlendra.kumar@intel.com>
Link: https://patch.msgid.link/20250925054129.2199157-1-kaushlendra.kumar@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kaushlendra Kumar and committed by
Greg Kroah-Hartman
fe6193a3 02426233

+4 -2
+4 -2
drivers/base/firmware_loader/sysfs_upload.c
··· 100 100 return -EINVAL; 101 101 102 102 mutex_lock(&fwlp->lock); 103 - if (fwlp->progress == FW_UPLOAD_PROG_IDLE) 104 - ret = -ENODEV; 103 + if (fwlp->progress == FW_UPLOAD_PROG_IDLE) { 104 + mutex_unlock(&fwlp->lock); 105 + return -ENODEV; 106 + } 105 107 106 108 fwlp->ops->cancel(fwlp->fw_upload); 107 109 mutex_unlock(&fwlp->lock);