summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-03-18 13:20:08 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-25 09:04:07 +0100
commit2d202085d2dd53b8364a17050887a805c9e1601f (patch)
tree4da68e289697205c9685bf3e9adc3b81f194e7cc /sound
parent64195f022ae8c24e0abccc1545d557b064e73ed3 (diff)
downloadlinux-stable-2d202085d2dd53b8364a17050887a805c9e1601f.tar.gz
linux-stable-2d202085d2dd53b8364a17050887a805c9e1601f.tar.bz2
linux-stable-2d202085d2dd53b8364a17050887a805c9e1601f.zip
ALSA: usb-audio: Fix unintentional sign extension issue
commit 50b1affc891cbc103a2334ce909a026e25f4c84d upstream. The shifting of the u8 integer device by 24 bits to the left will be promoted to a 32 bit signed int and then sign-extended to a 64 bit unsigned long. In the event that the top bit of device is set then all then all the upper 32 bits of the unsigned long will end up as also being set because of the sign-extension. Fix this by casting device to an unsigned long before the shift. Addresses-Coverity: ("Unintended sign extension") Fixes: a07df82c7990 ("ALSA: usb-audio: Add DJM750 to Pioneer mixer quirk") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210318132008.15266-1-colin.king@canonical.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/mixer_quirks.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 448de77f43fd..5171b3dc1eb9 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -2883,7 +2883,7 @@ static int snd_djm_controls_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_v
u8 group = (private_value & SND_DJM_GROUP_MASK) >> SND_DJM_GROUP_SHIFT;
u16 value = elem->value.enumerated.item[0];
- kctl->private_value = ((device << SND_DJM_DEVICE_SHIFT) |
+ kctl->private_value = (((unsigned long)device << SND_DJM_DEVICE_SHIFT) |
(group << SND_DJM_GROUP_SHIFT) |
value);
@@ -2921,7 +2921,7 @@ static int snd_djm_controls_create(struct usb_mixer_interface *mixer,
value = device->controls[i].default_value;
knew.name = device->controls[i].name;
knew.private_value = (
- (device_idx << SND_DJM_DEVICE_SHIFT) |
+ ((unsigned long)device_idx << SND_DJM_DEVICE_SHIFT) |
(i << SND_DJM_GROUP_SHIFT) |
value);
err = snd_djm_controls_update(mixer, device_idx, i, value);