firmware: cs_dsp: Remove __free() from cs_dsp_debugfs_string_read()
Subsystems (2)
Richard Fitzgerald
maintainerPATCH 1/1 firmware: cs_dsp: Remove __free() from cs_dsp_debugfs_string_read()
Don't use __free(kfree) in cs_dsp_debugfs_string_read. Instead use normal kfree() to cleanup.
The use of __free() can create new cleanup bugs that are difficult to spot because the defective code is idiomatically correct regular C. This function used the suspect declaration __free(kfree) = NULL;.
The __free(kfree) didn't really do anything here. The function can be rearranged to avoid any need to return or goto within the code.
--- drivers/firmware/cirrus/cs_dsp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/firmware/cirrus/cs_dsp.c +14 -9
@@ -375,18 +375,23 @@ static ssize_t cs_dsp_debugfs_string_read(struct cs_dsp *dsp, size_t count, loff_t *ppos, const char **pstr) { - const char *str __free(kfree) = NULL; + const char *str; +ssize_t ret =0 ; scoped_guard(mutex, &dsp->pwr_lock) { -if (!*pstr) -return 0 ; - - str =kasprintf (GFP_KERNEL ,"%s\n" , *pstr); -if (!str) -return -ENOMEM ; - -return simple_read_from_buffer (user_buf, count, ppos, str,strlen (str)); +if (*pstr) { + str =kasprintf (GFP_KERNEL ,"%s\n" , *pstr); +if (str) { + ret =simple_read_from_buffer (user_buf, count, + ppos, str,strlen (str)); +kfree (str); + }else { + ret = -ENOMEM ; + } + } } + +return ret; } static ssize_t cs_dsp_debugfs_wmfw_read(struct file *file,
Signature · 1 line
2.47.3
Quoted 8 lines · Richard Fitzgerald
Don't use
__free(kfree)incs_dsp_debugfs_string_read. Instead use normalkfree()to cleanup.The use of
__free()can create new cleanup bugs that are difficult to spot because the defective code is idiomatically correct regular C. This function used the suspect declaration__free(kfree)= NULL;.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] firmware: cs_dsp: Remove __free() from cs_dsp_debugfs_string_read()
commit: 7a9fa7fda93b7b3ae515f40f67bbf8e1d16337e8
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