accel/qaic: Cancel Sahara read data work on removal
Subsystems (4)
PATCH 1/1 accel/qaic: Cancel Sahara read data work on removal
Sahara removal cancels fw_work and dump_work, but leaves read_data_work pending or running. The latter accesses the firmware and the device-managed context and transfer buffer, which are released during removal.
Cancel read_data_work after fw_work, which can schedule it, and before releasing the firmware. The MHI core suspends and resets the channels before invoking the driver's remove callback.
This issue was identified during our ongoing static-analysis research while reviewing kernel code. The same omission was also reported by the Sashiko bot while reviewing the Sahara relocation series.
---
Validated with static source review, apply checks and strict checkpatch. No build or runtime testing was performed.
drivers/accel/qaic/sahara.c | 1 + 1 file changed, 1 insertion(+)
drivers/accel/qaic/sahara.c +1 -0
@@ -879,6 +879,7 @@ static void sahara_mhi_remove(struct mhi_device *mhi_dev)struct sahara_context *context =dev_get_drvdata (&mhi_dev->dev);cancel_work_sync (&context->fw_work); +cancel_work_sync (&context->read_data_work);cancel_work_sync (&context->dump_work);vfree (context->mem_dump);sahara_release_image (context);
Signature · 1 line
2.47.1
Quoted 31 lines · Myeonghun Pak
Sahara removal cancels
fw_workanddump_work, but leavesread_data_workpending or running. The latter accesses the firmware and the device-managed context and transfer buffer, which are released during removal.Cancel
read_data_workafterfw_work, which can schedule it, and before releasing the firmware. The MHI core suspends and resets the channels before invoking the driver's remove callback.This issue was identified during our ongoing static-analysis research while reviewing kernel code. The same omission was also reported by the Sashiko bot while reviewing the Sahara relocation series.
Fixes 7fb19ea1ec6a ("accel/qaic: Support the new READ_DATA implementation")Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>---
Validated with static source review, apply checks and strict checkpatch. No build or runtime testing was performed.drivers/accel/qaic/sahara.c | 1 + 1 file changed, 1 insertion(+)drivers/accel/qaic/sahara.c +0
-0
drivers/accel/qaic/sahara.c static void sahara_mhi_remove(struct mhi_device *mhi_dev) · line 882
Quoted 4 lines
drivers/accel/qaic/sahara.c +1
-0@@ -879,6 +879,7 @@ static void sahara_mhi_remove(struct mhi_device *mhi_dev)struct sahara_context *context =dev_get_drvdata (&mhi_dev->dev);cancel_work_sync (&context->fw_work); +cancel_work_sync (&context->read_data_work);
The typical convention is that ordering of operations in remove() is related to the order of operations in probe(). Adding this line here is arbitrary where it would fit the convention better if moved one line down.
I'll fix that up when applying this.
drivers/accel/qaic/sahara.c static void sahara_mhi_remove(struct mhi_device *mhi_dev) · line 885
Quoted 3 lines
drivers/accel/qaic/sahara.c +0
-0cancel_work_sync (&context->dump_work);vfree (context->mem_dump);sahara_release_image (context);
Quoted 12 lines · Myeonghun Pak
Sahara removal cancels
fw_workanddump_work, but leavesread_data_workpending or running. The latter accesses the firmware and the device-managed context and transfer buffer, which are released during removal.Cancel
read_data_workafterfw_work, which can schedule it, and before releasing the firmware. The MHI core suspends and resets the channels before invoking the driver's remove callback.This issue was identified during our ongoing static-analysis research while reviewing kernel code. The same omission was also reported by the Sashiko bot while reviewing the Sahara relocation series.
Quoted 7 lines
Fixes 7fb19ea1ec6a ("accel/qaic: Support the new READ_DATA implementation")Assisted-by LLMCo-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>
Pushed to drm-misc-next
-Jeff