ASoC: wm_adsp: Use vmemdup_user() instead of open-coding
Subsystems (3)
PATCH 1/1 ASoC: wm_adsp: Use vmemdup_user() instead of open-coding
Use vmemdup_user() to get a copy of the user buffer in wm_coeff_tlv_put().
Apart from simplifying the code and avoiding open-coding, it means we also automatically benefit from any security enhancements in the code behind vmemdup_user().
--- sound/soc/codecs/wm_adsp.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
sound/soc/codecs/wm_adsp.c +6 -14
@@ -8,6 +8,7 @@*/ #include <linux/array_size.h> +#include <linux/cleanup.h> #include <linux/ctype.h> #include <linux/module.h> #include <linux/moduleparam.h>
@@ -19,7 +20,7 @@#include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> -#include <linux/vmalloc.h> +#include <linux/string.h> #include <linux/workqueue.h> #include <linux/debugfs.h> #include <sound/core.h>
@@ -415,21 +416,12 @@ static int wm_coeff_tlv_put(struct snd_kcontrol *kctl, (struct soc_bytes_ext *)kctl->private_value;struct wm_coeff_ctl *ctl =bytes_ext_to_ctl (bytes_ext);struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; -void *scratch; -int ret =0 ; + void *scratch __free(kvfree) = vmemdup_user(bytes, size); - scratch =vmalloc (size); -if (!scratch) -return -ENOMEM ; +if (IS_ERR (scratch)) +return PTR_ERR (no_free_ptr (scratch)); -if (copy_from_user (scratch, bytes, size)) - ret = -EFAULT ; -else - ret =cs_dsp_coeff_lock_and_write_ctrl (cs_ctl,0 , scratch, size); - -vfree (scratch); - -return ret; +return cs_dsp_coeff_lock_and_write_ctrl (cs_ctl,0 , scratch, size); } static int wm_coeff_put_acked(struct snd_kcontrol *kctl,
Signature · 1 line
2.39.5
Mark Brown
maintainerQuoted 8 lines · Richard Fitzgerald
Use
vmemdup_user()to get a copy of the user buffer inwm_coeff_tlv_put().Apart from simplifying the code and avoiding open-coding, it means we also automatically benefit from any security enhancements in the code behind
vmemdup_user().[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: wm_adsp: Use vmemdup_user() instead of open-coding
commit: b5d057a86e2086af0b1e6d0ca8b306be1c73a627
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