Skip to content

Commit ea57680

Browse files
error27broonie
authored andcommitted
ASoC: SOF: ipc4-mtrace: prevent underflow in sof_ipc4_priority_mask_dfs_write()
The "id" comes from the user. Change the type to unsigned to prevent an array underflow. Fixes: f4ea22f ("ASoC: SOF: ipc4: Add support for mtrace log extraction") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Peter Ujfalusi <[email protected]> Link: https://lore.kernel.org/r/Y8laruWOEwOC/dx9@kili Signed-off-by: Mark Brown <[email protected]>
1 parent c1619ea commit ea57680

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sound/soc/sof/ipc4-mtrace.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,10 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file,
344344
size_t count, loff_t *ppos)
345345
{
346346
struct sof_mtrace_priv *priv = file->private_data;
347-
int id, ret;
347+
unsigned int id;
348348
char *buf;
349349
u32 mask;
350+
int ret;
350351

351352
/*
352353
* To update Nth mask entry, write:
@@ -357,9 +358,9 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file,
357358
if (IS_ERR(buf))
358359
return PTR_ERR(buf);
359360

360-
ret = sscanf(buf, "%d,0x%x", &id, &mask);
361+
ret = sscanf(buf, "%u,0x%x", &id, &mask);
361362
if (ret != 2) {
362-
ret = sscanf(buf, "%d,%x", &id, &mask);
363+
ret = sscanf(buf, "%u,%x", &id, &mask);
363364
if (ret != 2) {
364365
ret = -EINVAL;
365366
goto out;

0 commit comments

Comments
 (0)