Skip to content

Commit fb8cd64

Browse files
Lawliartiwai
authored andcommitted
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 <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/BL0PR06MB4548170B842CB055C9AF695DE5B00@BL0PR06MB4548.namprd06.prod.outlook.com Signed-off-by: Takashi Iwai <[email protected]>
1 parent 259eb82 commit fb8cd64

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/core/hwdep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
216216
if (info.index >= 32)
217217
return -EINVAL;
218218
/* check whether the dsp was already loaded */
219-
if (hw->dsp_loaded & (1 << info.index))
219+
if (hw->dsp_loaded & (1u << info.index))
220220
return -EBUSY;
221221
err = hw->ops.dsp_load(hw, &info);
222222
if (err < 0)
223223
return err;
224-
hw->dsp_loaded |= (1 << info.index);
224+
hw->dsp_loaded |= (1u << info.index);
225225
return 0;
226226
}
227227

0 commit comments

Comments
 (0)