ASoC: SOF: icp3-dtrace: Fix wrong kfree() usage
Subsystems (3)
PATCH 1/1 ASoC: SOF: icp3-dtrace: Fix wrong kfree() usage
trace_filter_parse() allocs memory for *out and when -ENOMEM is returned, caller function, dfsentry_trace_filter_write() trying to freed this memory.
After this patch, the memory is freed in trace_filter_parse() before -EINVAL returned. In caller function removed kfree(elms) from error label
--- sound/soc/sof/ipc3-dtrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sof/ipc3-dtrace.c +2 -1
@@ -137,6 +137,7 @@ static int trace_filter_parse(struct snd_sof_dev *sdev, char *string,dev_err (sdev->dev,"Parsing filter entry '%s' failed with %d\n" , entry, entry_len); +kfree (*out);return -EINVAL ; } }
@@ -208,13 +209,13 @@ static ssize_t dfsentry_trace_filter_write(struct file *file, const char __user ret =ipc3_trace_update_filter (sdev, num_elems, elems);if (ret <0 ) {dev_err (sdev->dev,"Filter update failed: %d\n" , ret); +kfree (elems); goto error; } } ret = count; error:kfree (string); -kfree (elems);return ret; }
Signature · 1 line
2.42.0.windows.2
Péter Ujfalusi
maintainerQuoted 7 lines · Kamil Duljas
trace_filter_parse()allocs memory for *out and when-ENOMEMis returned, caller function,dfsentry_trace_filter_write()trying to freed this memory.After this patch, the memory is freed in
trace_filter_parse()before-EINVALreturned. In caller function removed kfree(elms) from error label
I think the original code was cleaner:
the elems is always freed up in dfsentry_trace_filter_write() in one place. kfree(NULL); is not an error, it is handled correctly
Quoted 33 lines
Signed-off-by Kamil Duljas <[email protected]>--- sound/soc/sof/ipc3-dtrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)sound/soc/sof/ipc3-dtrace.c +2
-1@@ -137,6 +137,7 @@ static int trace_filter_parse(struct snd_sof_dev *sdev, char *string,dev_err (sdev->dev,"Parsing filter entry '%s' failed with %d\n" , entry, entry_len); +kfree (*out);return -EINVAL ; } }@@ -208,13 +209,13 @@ static ssize_t dfsentry_trace_filter_write(struct file *file, const char __user ret =ipc3_trace_update_filter (sdev, num_elems, elems);if (ret <0 ) {dev_err (sdev->dev,"Filter update failed: %d\n" , ret); +kfree (elems); goto error; } } ret = count; error:kfree (string); -kfree (elems);return ret; }
Signature · 1 line
Péter
Mark Brown
maintainerQuoted 9 lines · Kamil Duljas
trace_filter_parse()allocs memory for *out and when-ENOMEMis returned, caller function,dfsentry_trace_filter_write()trying to freed this memory.After this patch, the memory is freed in
trace_filter_parse()before-EINVALreturned. In caller function removed kfree(elms) from error label[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: SOF: icp3-dtrace: Fix wrong kfree() usage
commit: 8c91ca76f44804868d12aed20ebdbc2f89aa7d60
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark