]>
Commit | Line | Data |
---|---|---|
72c0f505 GKH |
1 | From 889d66848b12d891248b03abcb2a42047f8e172a Mon Sep 17 00:00:00 2001 |
2 | From: Eldad Zack <eldad@fogrefinery.com> | |
3 | Date: Fri, 5 Apr 2013 20:49:46 +0200 | |
4 | Subject: ALSA: usb-audio: fix endianness bug in snd_nativeinstruments_* | |
5 | ||
6 | From: Eldad Zack <eldad@fogrefinery.com> | |
7 | ||
8 | commit 889d66848b12d891248b03abcb2a42047f8e172a upstream. | |
9 | ||
10 | The usb_control_msg() function expects __u16 types and performs | |
11 | the endianness conversions by itself. | |
12 | However, in three places, a conversion is performed before it is | |
13 | handed over to usb_control_msg(), which leads to a double conversion | |
14 | (= no conversion): | |
15 | * snd_usb_nativeinstruments_boot_quirk() | |
16 | * snd_nativeinstruments_control_get() | |
17 | * snd_nativeinstruments_control_put() | |
18 | ||
19 | Caught by sparse: | |
20 | ||
21 | sound/usb/mixer_quirks.c:512:38: warning: incorrect type in argument 6 (different base types) | |
22 | sound/usb/mixer_quirks.c:512:38: expected unsigned short [unsigned] [usertype] index | |
23 | sound/usb/mixer_quirks.c:512:38: got restricted __le16 [usertype] <noident> | |
24 | sound/usb/mixer_quirks.c:543:35: warning: incorrect type in argument 5 (different base types) | |
25 | sound/usb/mixer_quirks.c:543:35: expected unsigned short [unsigned] [usertype] value | |
26 | sound/usb/mixer_quirks.c:543:35: got restricted __le16 [usertype] <noident> | |
27 | sound/usb/mixer_quirks.c:543:56: warning: incorrect type in argument 6 (different base types) | |
28 | sound/usb/mixer_quirks.c:543:56: expected unsigned short [unsigned] [usertype] index | |
29 | sound/usb/mixer_quirks.c:543:56: got restricted __le16 [usertype] <noident> | |
30 | sound/usb/quirks.c:502:35: warning: incorrect type in argument 5 (different base types) | |
31 | sound/usb/quirks.c:502:35: expected unsigned short [unsigned] [usertype] value | |
32 | sound/usb/quirks.c:502:35: got restricted __le16 [usertype] <noident> | |
33 | ||
34 | Signed-off-by: Eldad Zack <eldad@fogrefinery.com> | |
35 | Acked-by: Daniel Mack <zonque@gmail.com> | |
36 | Signed-off-by: Takashi Iwai <tiwai@suse.de> | |
37 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
38 | ||
39 | --- | |
40 | sound/usb/mixer_quirks.c | 4 ++-- | |
41 | sound/usb/quirks.c | 2 +- | |
42 | 2 files changed, 3 insertions(+), 3 deletions(-) | |
43 | ||
44 | --- a/sound/usb/mixer_quirks.c | |
45 | +++ b/sound/usb/mixer_quirks.c | |
46 | @@ -509,7 +509,7 @@ static int snd_nativeinstruments_control | |
47 | else | |
48 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest, | |
49 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, | |
50 | - 0, cpu_to_le16(wIndex), | |
51 | + 0, wIndex, | |
52 | &tmp, sizeof(tmp), 1000); | |
53 | up_read(&mixer->chip->shutdown_rwsem); | |
54 | ||
55 | @@ -540,7 +540,7 @@ static int snd_nativeinstruments_control | |
56 | else | |
57 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest, | |
58 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, | |
59 | - cpu_to_le16(wValue), cpu_to_le16(wIndex), | |
60 | + wValue, wIndex, | |
61 | NULL, 0, 1000); | |
62 | up_read(&mixer->chip->shutdown_rwsem); | |
63 | ||
64 | --- a/sound/usb/quirks.c | |
65 | +++ b/sound/usb/quirks.c | |
66 | @@ -486,7 +486,7 @@ static int snd_usb_nativeinstruments_boo | |
67 | { | |
68 | int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | |
69 | 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, | |
70 | - cpu_to_le16(1), 0, NULL, 0, 1000); | |
71 | + 1, 0, NULL, 0, 1000); | |
72 | ||
73 | if (ret < 0) | |
74 | return ret; |