Skip to content

Commit 4790af1

Browse files
Chancel Liubroonie
authored andcommitted
ASoC: fsl_sai: Fix 32 slots TDM broken by integer shift UB in xMR write
When configuring 32 slots TDM (channels == slots == 32), the xMR (Mask Register) write used: ~0UL - ((1 << min(channels, slots)) - 1) The literal "1" is a signed 32-bit int. Shifting it by 32 positions is undefined behaviour which may set this register to 0xFFFFFFFF, masking all 32 slots. Use GENMASK_U32() macro instead. For 32 slots this produces a zero mask: ~GENMASK_U32(31, 0) = ~0xFFFFFFFF = 0x00000000 Behaviour for fewer than 32 slots is unchanged. Fixes: 770f58d ("ASoC: fsl_sai: Support multiple data channel enable bits") Cc: stable@vger.kernel.org Signed-off-by: Chancel Liu <chancel.liu@nxp.com> Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com> Link: https://patch.msgid.link/20260601083327.1535185-1-chancel.liu@oss.nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c9c6482 commit 4790af1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

sound/soc/fsl/fsl_sai.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
793793
FSL_SAI_CR4_FSD_MSTR, FSL_SAI_CR4_FSD_MSTR);
794794

795795
regmap_write(sai->regmap, FSL_SAI_xMR(tx),
796-
~0UL - ((1 << min(channels, slots)) - 1));
796+
~GENMASK_U32(min(channels, slots) - 1, 0));
797797

798798
return 0;
799799
}

0 commit comments

Comments
 (0)