summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorChangming Liu <liu.changm@northeastern.edu>2020-05-26 00:39:21 +0000
committerTakashi Iwai <tiwai@suse.de>2020-05-26 08:18:24 +0200
commitfb8cd6481ffd126f35e9e146a0dcf0c4e8899f2e (patch)
tree11ad21509a11fbbde361a819ad867e7d54531236 /sound
parent259eb82475316672a5d682a94dc8bdd53cf8d8c3 (diff)
downloadlinux-fb8cd6481ffd126f35e9e146a0dcf0c4e8899f2e.tar.gz
linux-fb8cd6481ffd126f35e9e146a0dcf0c4e8899f2e.tar.bz2
linux-fb8cd6481ffd126f35e9e146a0dcf0c4e8899f2e.zip
ALSA: hwdep: fix a left shifting 1 by 31 UB bug
The "info.index" variable can be 31 in "1 << info.index". This might trigger an undefined behavior since 1 is signed. Fix this by casting 1 to 1u just to be sure "1u << 31" is defined. Signed-off-by: Changming Liu <liu.changm@northeastern.edu> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/BL0PR06MB4548170B842CB055C9AF695DE5B00@BL0PR06MB4548.namprd06.prod.outlook.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/hwdep.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index b412d3b3d5ff..21edb8ac95eb 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
if (info.index >= 32)
return -EINVAL;
/* check whether the dsp was already loaded */
- if (hw->dsp_loaded & (1 << info.index))
+ if (hw->dsp_loaded & (1u << info.index))
return -EBUSY;
err = hw->ops.dsp_load(hw, &info);
if (err < 0)
return err;
- hw->dsp_loaded |= (1 << info.index);
+ hw->dsp_loaded |= (1u << info.index);
return 0;
}