Input: cs40l50 - fix OWT upload length
Subsystems (4)
PATCH 1/2 Input: cs40l50 - fix OWT upload length
cs40l50_upload_owt() passes the size of the effect in bytes as the val_count argument of regmap_bulk_write(). The cs40l50 regmap uses 32-bit registers, so val_count is a number of registers and the call covers four times the intended length.
regmap_bulk_write() copies val_count * val_bytes bytes from the source buffer, so this reads past the end of new_owt_effect_data, which is only sizeof(header) + len bytes long, and writes the extra data to the DSP beyond the end of the uploaded effect. The free space check above only covers the real size of the effect, so the write can also go past the space reported as available in the open wavetable.
Pass the length in 32-bit words, matching header.data_words.
---
Build-tested only (W=1, x86_64 defconfig with the CS40L50 drivers as modules). I do not have CS40L50 hardware, so this was not runtime tested.
drivers/input/misc/cs40l50-vibra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/misc/cs40l50-vibra.c +1 -1
@@ -250,7 +250,7 @@ static int cs40l50_upload_owt(struct cs40l50_work *work_data) error =regmap_bulk_write (vib->regmap, vib->dsp.owt_base_reg + (offset *sizeof (u32)), new_owt_effect_data, -sizeof (header) + len); + (sizeof (header) + len) /sizeof (u32));if (error)return error;
Signature · 1 line
2.56.0
PATCH 2/2 Input: cs40l50 - fix work item leak in stop worker
cs40l50_playback() allocates a work item for every playback request, and the start and stop workers are responsible for freeing it. cs40l50_stop_worker() returns early when pm_runtime_resume_and_get() fails and never frees the item.
Free it on that path too, as cs40l50_start_worker() already does.
---
Build-tested only (W=1, x86_64 defconfig with the CS40L50 drivers as modules). I do not have CS40L50 hardware, so this was not runtime tested.
drivers/input/misc/cs40l50-vibra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/misc/cs40l50-vibra.c +2 -2
@@ -384,12 +384,12 @@ static void cs40l50_stop_worker(struct work_struct *work)struct cs40l50_vibra *vib = work_data->vib;if (pm_runtime_resume_and_get (vib->dev) <0 ) -return ; + goto err_free; vib->dsp.write (vib->dev, vib->regmap, vib->dsp.stop_cmd);pm_runtime_put_autosuspend (vib->dev); - +err_free:kfree (work_data); }
Signature · 1 line
2.56.0
Hi Dmitry,
Gentle ping on this two-patch series. Patch 1 fixes an out-of-bounds read in cs40l50_upload_owt(), where regmap_bulk_write() gets a byte count instead of a register count. Patch 2 fixes a work item leak in the stop worker.
I can rebase or resend if that helps.
Thanks,
Ismail