summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2019-06-27 12:58:53 -0400
committerTakashi Iwai <tiwai@suse.de>2019-06-28 04:41:17 -0400
commit3fc4147653130c5d49d07e06186628e29ba9f39d (patch)
tree8c54904723ccb91d62799875f7670168cfae5796
parent801ebf1043ae7b182588554cc9b9ad3c14bc2ab5 (diff)
ALSA: xen-front: fix unintention integer overflow on left shifts
Shifting the integer value 1 is evaluated using 32-bit arithmetic and then used in an expression that expects a 64-bit value, so there is potentially an integer overflow. Fix this by using the BIT_ULL macro to perform the shift. [ Note: as of the time being, no actual integer overflow hits because all values are less than 32bit, not including the extended 3-byte or DSD formats. But this is the right fix for future usage, of course. -- tiwai ] Addresses-Coverity: ("Unintentional integer overflow") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/xen/xen_snd_front_alsa.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
index b14ab512c2ce..e01631959ed8 100644
--- a/sound/xen/xen_snd_front_alsa.c
+++ b/sound/xen/xen_snd_front_alsa.c
@@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
196 mask = 0; 196 mask = 0;
197 for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++) 197 for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
198 if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats) 198 if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
199 mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif; 199 mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
200 200
201 return mask; 201 return mask;
202} 202}
@@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
208 208
209 mask = 0; 209 mask = 0;
210 for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++) 210 for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
211 if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats) 211 if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
212 mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa); 212 mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
213 213
214 return mask; 214 return mask;