The work we schedule on register deletes himself. Therefor we cannot
use cancel_work_sync() because that calls flush_work() but still uses
the pointer to the (now deleted) work afterwards (for clear_work_data)
which ends up in a bug.
Replacing cancel_work_sync() with flush_work() fixes that.

Signed-off-by: Alexander Holler <[email protected]>
---

 This patch applies on top of PATCH 3/4 or 4/4 of the small series of 4 patches
 for rtc-hid-sensor-time, which was already merged into the -mm tree.

 drivers/rtc/rtc-hid-sensor-time.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-hid-sensor-time.c 
b/drivers/rtc/rtc-hid-sensor-time.c
index 4aca12d..acb2bc2 100644
--- a/drivers/rtc/rtc-hid-sensor-time.c
+++ b/drivers/rtc/rtc-hid-sensor-time.c
@@ -414,9 +414,8 @@ static int hid_time_remove(struct platform_device *pdev)
        struct hid_time_state *time_state = platform_get_drvdata(pdev);
 
        if (time_state->workts) {
-               cancel_work_sync(&time_state->workts->work);
-               kfree(time_state->workts);
-               time_state->workts = NULL;
+               flush_work(&time_state->workts->work);
+               BUG_ON(time_state->workts != NULL);
        }
        sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
 
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to