]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ALSA: pcm: use new array-copying-wrapper
authorChenyuan Yang <chenyuan0y@gmail.com>
Mon, 27 Jan 2025 16:06:55 +0000 (10:06 -0600)
committerTakashi Iwai <tiwai@suse.de>
Tue, 28 Jan 2025 07:48:08 +0000 (08:48 +0100)
This is found by our static analysis tool.

pcm_native.c utilizes memdup_user() to copy an array from userspace.

There is a new wrapper, specifically designed for copying arrays. Use
this one instead.

This is similar to the
commit 3e91a38de1dc ("fbdev: viafb: use new array-copying-wrapper").

Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
Link: https://patch.msgid.link/20250127160655.3119470-1-cy1yang@outlook.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_native.c

index 8a3384342e8db083e31d0fa896352146e80fb121..6c2b6a62d9d2f8011e44cf0432daeaa553011d6d 100644 (file)
@@ -3245,7 +3245,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream,
        if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
                return -EFAULT;
 
-       bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels);
+       bufs = memdup_array_user(xfern.bufs, runtime->channels, sizeof(void *));
        if (IS_ERR(bufs))
                return PTR_ERR(bufs);
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)