Skip to content

Commit

Permalink
ALSA: usb-audio: fix sign unintended sign extension on left shifts
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Colin Ian King authored and tiwai committed Jun 28, 2019
1 parent 503d90b commit 2acf5a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sound/usb/mixer_quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2acf5a3

Please sign in to comment.