Commit ea57680a authored by Dan Carpenter's avatar Dan Carpenter Committed by Mark Brown

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: f4ea22f7 ("ASoC: SOF: ipc4: Add support for mtrace log extraction")
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Acked-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/Y8laruWOEwOC/dx9@kiliSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c1619ea2
...@@ -344,9 +344,10 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file, ...@@ -344,9 +344,10 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct sof_mtrace_priv *priv = file->private_data; struct sof_mtrace_priv *priv = file->private_data;
int id, ret; unsigned int id;
char *buf; char *buf;
u32 mask; u32 mask;
int ret;
/* /*
* To update Nth mask entry, write: * To update Nth mask entry, write:
...@@ -357,9 +358,9 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file, ...@@ -357,9 +358,9 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file,
if (IS_ERR(buf)) if (IS_ERR(buf))
return PTR_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) { if (ret != 2) {
ret = sscanf(buf, "%d,%x", &id, &mask); ret = sscanf(buf, "%u,%x", &id, &mask);
if (ret != 2) { if (ret != 2) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment