Skip to content

Commit 443449d

Browse files
Colin Ian Kinggregkh
authored andcommitted
ALSA: usb-audio: fix sign unintended sign extension on left shifts
commit 2acf5a3 upstream. 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 <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8b449e9 commit 443449d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/usb/mixer_quirks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ static int snd_ni_control_init_val(struct usb_mixer_interface *mixer,
753753
return err;
754754
}
755755

756-
kctl->private_value |= (value << 24);
756+
kctl->private_value |= ((unsigned int)value << 24);
757757
return 0;
758758
}
759759

@@ -914,7 +914,7 @@ static int snd_ftu_eff_switch_init(struct usb_mixer_interface *mixer,
914914
if (err < 0)
915915
return err;
916916

917-
kctl->private_value |= value[0] << 24;
917+
kctl->private_value |= (unsigned int)value[0] << 24;
918918
return 0;
919919
}
920920

0 commit comments

Comments
 (0)