Commit fb8cd648 authored by Changming Liu's avatar Changming Liu Committed by Takashi Iwai

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: default avatarChangming Liu <liu.changm@northeastern.edu>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/BL0PR06MB4548170B842CB055C9AF695DE5B00@BL0PR06MB4548.namprd06.prod.outlook.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 259eb824
...@@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw, ...@@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
if (info.index >= 32) if (info.index >= 32)
return -EINVAL; return -EINVAL;
/* check whether the dsp was already loaded */ /* check whether the dsp was already loaded */
if (hw->dsp_loaded & (1 << info.index)) if (hw->dsp_loaded & (1u << info.index))
return -EBUSY; return -EBUSY;
err = hw->ops.dsp_load(hw, &info); err = hw->ops.dsp_load(hw, &info);
if (err < 0) if (err < 0)
return err; return err;
hw->dsp_loaded |= (1 << info.index); hw->dsp_loaded |= (1u << info.index);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment