From: Hongbo Li Date: Sat, 31 Aug 2024 08:06:39 +0000 (+0800) Subject: ALSA: pcm: replace simple_strtoul to kstrtoul X-Git-Tag: v6.12-rc1~169^2~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61bc4deff033181992408f973b48fca08757d3ff;p=thirdparty%2Fkernel%2Flinux.git ALSA: pcm: replace simple_strtoul to kstrtoul As mentioned in [1], "...simple_strtol(), simple_strtoll(), simple_strtoul(), and simple_strtoull() functions explicitly ignore overflows, which may lead to unexpected results in callers." Hence, the use of those functions is discouraged. This patch replace the use of the simple_strtoul with the safer alternatives kstrtoul. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#simple-strtol-simple-strtoll-simple-strtoul-simple-strtoull Signed-off-by: Hongbo Li Link: https://patch.msgid.link/20240831080639.3985143-1-lihongbo22@huawei.com Signed-off-by: Takashi Iwai --- diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 8e4c68e3bbd0a..73d4fc49a0ca3 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -193,7 +193,10 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, } if (!snd_info_get_line(buffer, line, sizeof(line))) { snd_info_get_str(str, line, sizeof(str)); - size = simple_strtoul(str, NULL, 10) * 1024; + buffer->error = kstrtoul(str, 10, &size); + if (buffer->error != 0) + return; + size *= 1024; if ((size != 0 && size < 8192) || size > substream->dma_max) { buffer->error = -EINVAL; return;