aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/control_compat.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2020-09-18 11:56:19 +0200
committerTakashi Iwai <tiwai@suse.de>2020-09-21 10:37:07 +0200
commit18d122c0287b29e70bc312a994c7ee79738cec77 (patch)
tree5310fec9f6a909f465b97350cf4fda5105149361 /sound/core/control_compat.c
parentALSA: asihpi: fix spellint typo in comments (diff)
downloadlinux-dev-18d122c0287b29e70bc312a994c7ee79738cec77.tar.xz
linux-dev-18d122c0287b29e70bc312a994c7ee79738cec77.zip
ALSA: compat_ioctl: avoid compat_alloc_user_space
Using compat_alloc_user_space() tends to add complexity to the ioctl handling, so I am trying to remove it everywhere. The two callers in sound/core can rewritten to just call the same code that operates on a kernel pointer as the native handler. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20200918095642.1446243-1-arnd@arndb.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control_compat.c')
-rw-r--r--sound/core/control_compat.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 02df1d7db9a1..1d708aab9c98 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -22,24 +22,22 @@ struct snd_ctl_elem_list32 {
static int snd_ctl_elem_list_compat(struct snd_card *card,
struct snd_ctl_elem_list32 __user *data32)
{
- struct snd_ctl_elem_list __user *data;
+ struct snd_ctl_elem_list data = {};
compat_caddr_t ptr;
int err;
- data = compat_alloc_user_space(sizeof(*data));
-
/* offset, space, used, count */
- if (copy_in_user(data, data32, 4 * sizeof(u32)))
+ if (copy_from_user(&data, data32, 4 * sizeof(u32)))
return -EFAULT;
/* pids */
- if (get_user(ptr, &data32->pids) ||
- put_user(compat_ptr(ptr), &data->pids))
+ if (get_user(ptr, &data32->pids))
return -EFAULT;
- err = snd_ctl_elem_list(card, data);
+ data.pids = compat_ptr(ptr);
+ err = snd_ctl_elem_list(card, &data);
if (err < 0)
return err;
/* copy the result */
- if (copy_in_user(data32, data, 4 * sizeof(u32)))
+ if (copy_to_user(data32, &data, 4 * sizeof(u32)))
return -EFAULT;
return 0;
}