Skip to content

Commit 5c822c0

Browse files
Yuan Candtor
authored andcommitted
Input: cs40l50 - fix wrong usage of INIT_WORK()
In cs40l50_add(), the work_data is a local variable and the work_data.work should initialize with INIT_WORK_ONSTACK() instead of INIT_WORK(). Small error in cs40l50_erase() also fixed in this commit. Fixes: c38fe1b ("Input: cs40l50 - Add support for the CS40L50 haptic driver") Signed-off-by: Yuan Can <yuancan@huawei.com> Reviewed-by: James Ogletree <jogletre@opensource.cirrus.com> Link: https://lore.kernel.org/r/20241106013549.78142-1-yuancan@huawei.com Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 071b24b commit 5c822c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/input/misc/cs40l50-vibra.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,12 @@ static int cs40l50_add(struct input_dev *dev, struct ff_effect *effect,
334334
work_data.custom_len = effect->u.periodic.custom_len;
335335
work_data.vib = vib;
336336
work_data.effect = effect;
337-
INIT_WORK(&work_data.work, cs40l50_add_worker);
337+
INIT_WORK_ONSTACK(&work_data.work, cs40l50_add_worker);
338338

339339
/* Push to the workqueue to serialize with playbacks */
340340
queue_work(vib->vib_wq, &work_data.work);
341341
flush_work(&work_data.work);
342+
destroy_work_on_stack(&work_data.work);
342343

343344
kfree(work_data.custom_data);
344345

@@ -467,11 +468,12 @@ static int cs40l50_erase(struct input_dev *dev, int effect_id)
467468
work_data.vib = vib;
468469
work_data.effect = &dev->ff->effects[effect_id];
469470

470-
INIT_WORK(&work_data.work, cs40l50_erase_worker);
471+
INIT_WORK_ONSTACK(&work_data.work, cs40l50_erase_worker);
471472

472473
/* Push to workqueue to serialize with playbacks */
473474
queue_work(vib->vib_wq, &work_data.work);
474475
flush_work(&work_data.work);
476+
destroy_work_on_stack(&work_data.work);
475477

476478
return work_data.error;
477479
}

0 commit comments

Comments
 (0)