Skip to contentSkip to conversation

ASoC: SOF: icp3-dtrace: Revert "Fix wrong kfree() usage"

PATCH In review Peter Ujfalusi 2 participants 2 messages Jan 12, 2024

Subsystems (3)
lore
Share & tools
lore

Peter Ujfalusi

author maintainer
#0 lore raw

PATCH v2 1/1 ASoC: SOF: icp3-dtrace: Revert "Fix wrong kfree() usage"

The offending patch introduces memory leak when there is no error, the memory allocated for the temporary storage is not freed up.

As I have commented, the original code was correct and cleaner to follow but it was not obvious from the patch that it will introduce regression.

Fixes 8c91ca76f448 ("ASoC: SOF: icp3-dtrace: Fix wrong kfree() usage")
---
 sound/soc/sof/ipc3-dtrace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/sof/ipc3-dtrace.c +1 -2
index 93b189c2d2ee..0dca139322f3 100644
@@ -137,7 +137,6 @@ 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;
 		}
 	}
@@ -209,13 +208,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.43.0
maintainer
#1 lore raw
Quoted 8 lines · Peter Ujfalusi

The offending patch introduces memory leak when there is no error, the memory allocated for the temporary storage is not freed up.

As I have commented, the original code was correct and cleaner to follow but it was not obvious from the patch that it will introduce regression.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: icp3-dtrace: Revert "Fix wrong kfree() usage"

      commit: 813c2f2925ee9c10dc4acd5aa7410cd3357e8da8

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