]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ALSA: usb-audio: fix sign unintended sign extension on left shifts
authorColin Ian King <colin.king@canonical.com>
Thu, 27 Jun 2019 16:43:08 +0000 (17:43 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 28 Jun 2019 08:37:34 +0000 (10:37 +0200)
There are a couple of left shifts of unsigned 8 bit values that
first get promoted to signed ints and hence get sign extended
on the shift if the top bit of the 8 bit values are set. Fix
this by casting the 8 bit values to unsigned ints to stop the
unintentional sign extension.

Addresses-Coverity: ("Unintended sign extension")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/mixer_quirks.c

index a751a18ca4c286bfa3d5b27f7af226142909d40b..5783329a3237fbd906a70c6c09657844129533a7 100644 (file)
@@ -754,7 +754,7 @@ static int snd_ni_control_init_val(struct usb_mixer_interface *mixer,
                return err;
        }
 
-       kctl->private_value |= (value << 24);
+       kctl->private_value |= ((unsigned int)value << 24);
        return 0;
 }
 
@@ -915,7 +915,7 @@ static int snd_ftu_eff_switch_init(struct usb_mixer_interface *mixer,
        if (err < 0)
                return err;
 
-       kctl->private_value |= value[0] << 24;
+       kctl->private_value |= (unsigned int)value[0] << 24;
        return 0;
 }