Skip to content

Commit

Permalink
ASoC: SOF: ipc4-mtrace: prevent underflow in sof_ipc4_priority_mask_d…
Browse files Browse the repository at this point in the history
…fs_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]>
  • Loading branch information
error27 authored and broonie committed Jan 20, 2023
1 parent c1619ea commit ea57680
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sound/soc/sof/ipc4-mtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,10 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file,
size_t count, loff_t *ppos)
{
struct sof_mtrace_priv *priv = file->private_data;
int id, ret;
unsigned int id;
char *buf;
u32 mask;
int ret;

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

ret = sscanf(buf, "%d,0x%x", &id, &mask);
ret = sscanf(buf, "%u,0x%x", &id, &mask);
if (ret != 2) {
ret = sscanf(buf, "%d,%x", &id, &mask);
ret = sscanf(buf, "%u,%x", &id, &mask);
if (ret != 2) {
ret = -EINVAL;
goto out;
Expand Down

0 comments on commit ea57680

Please sign in to comment.