[alsa-devel] [PATCH 0/3] ALSA: usb-us122l: compatible ioctl support and fix sparse warnings
Hi,
This patchset is to fix some sparse warnings in ALSA USB US122L module. Additionally, compatible ioctl is supported.
Takashi Sakamoto (3): usb-us122l: replace 'unsigned' with 'unsigned int' usb-us122l: add support for compatible ioctl usb-us122l: add qualifier into pointer to userspace
sound/usb/usx2y/us122l.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
This fashion is preferable to checkpatch.pl.
WARNING: Prefer 'unsigned int' to bare use of 'unsigned
Fixes: 030a07e4412 ('ALSA: Add USB US122L driver') Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/usb/usx2y/us122l.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index cf5dc33..ace708f 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -377,7 +377,7 @@ out: }
static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, - unsigned cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { struct usb_stream_config *cfg; struct us122l *us122l = hw->private_data;
ALSA hwdep is a thin wrapper of usual ioctl operation, thus it's better to support compatible ioctl operation.
Currently, ALSA USB US122L module doesn't support it. This commit adds support for it.
Fixes: 030a07e4412 ('ALSA: Add USB US122L driver') Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/usb/usx2y/us122l.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index ace708f..36654ac 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -24,6 +24,7 @@ #include <sound/hwdep.h> #include <sound/pcm.h> #include <sound/initval.h> +#include <linux/compat.h> #define MODNAME "US122L" #include "usb_stream.c" #include "../usbaudio.h" @@ -453,6 +454,18 @@ free: return err; }
+#ifdef CONFIG_COMPAT +static int usb_stream_hwdep_compat_ioctl(struct snd_hwdep *hw, + struct file *file, + unsigned int cmd, unsigned long arg) +{ + return usb_stream_hwdep_compat_ioctl(hw, file, cmd, + (unsigned long)compat_ptr(arg)); +} +#else +#define usb_stream_hwdep_compat_ioctl NULL +#endif + #define SND_USB_STREAM_ID "USB STREAM" static int usb_stream_hwdep_new(struct snd_card *card) { @@ -469,7 +482,7 @@ static int usb_stream_hwdep_new(struct snd_card *card) hw->ops.open = usb_stream_hwdep_open; hw->ops.release = usb_stream_hwdep_release; hw->ops.ioctl = usb_stream_hwdep_ioctl; - hw->ops.ioctl_compat = usb_stream_hwdep_ioctl; + hw->ops.ioctl_compat = usb_stream_hwdep_compat_ioctl; hw->ops.mmap = usb_stream_hwdep_mmap; hw->ops.poll = usb_stream_hwdep_poll;
On Wed, 27 Jul 2016 17:06:47 +0200, Takashi Sakamoto wrote:
+#ifdef CONFIG_COMPAT +static int usb_stream_hwdep_compat_ioctl(struct snd_hwdep *hw,
struct file *file,
unsigned int cmd, unsigned long arg)
+{
- return usb_stream_hwdep_compat_ioctl(hw, file, cmd,
(unsigned long)compat_ptr(arg));
Won't this go into the endless recursion?
Takashi
On Jul 28 2016 00:08, Takashi Iwai wrote:
On Wed, 27 Jul 2016 17:06:47 +0200, Takashi Sakamoto wrote:
+#ifdef CONFIG_COMPAT +static int usb_stream_hwdep_compat_ioctl(struct snd_hwdep *hw,
struct file *file,
unsigned int cmd, unsigned long arg)
+{
- return usb_stream_hwdep_compat_ioctl(hw, file, cmd,
(unsigned long)compat_ptr(arg));
Won't this go into the endless recursion?
Oh, indeed. I did just copy-and-paste here... I'll post revised version, later.
Thanks
Takashi Sakamoto
Sparse reports below warnings.
us122l.c:393:28: warning: incorrect type in argument 1 (different address spaces) us122l.c:393:28: expected void const [noderef] asn:1*<noident> us122l.c:393:28: got void *<noident>
The first argument for memdup_user() should be a pointer to userspace. In current implementation, a pointer to void is used without __user qualifier.
This commit fixes it.
Fixes: 030a07e4412 ('ALSA: Add USB US122L driver') Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/usb/usx2y/us122l.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 36654ac..c578c42 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -390,7 +390,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) return -ENOTTY;
- cfg = memdup_user((void *)arg, sizeof(*cfg)); + cfg = memdup_user((void __user *)arg, sizeof(*cfg)); if (IS_ERR(cfg)) return PTR_ERR(cfg);
participants (2)
-
Takashi Iwai
-
Takashi Sakamoto