Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: cs35l56: Prevent bad sign extension in cs35l56_read_silicon_uid()

Cast u8 values to u32 when using them to build a 32-bit unsigned value
that is then stored in a u64. This avoids the possibility of a bad sign
extension where the u8 is implicitly extended to an int, thus changing it
from an unsigned to a signed value.

Whether this is a real problem is debatable, but it does no harm to
ensure that the u8 are cast to a suitable type for shifting.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e1830f66f6c6 ("ASoC: cs35l56: Add helper functions for amp calibration")
Link: https://msgid.link/r/20240227100042.99-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Richard Fitzgerald and committed by
Mark Brown
cb9d8a2c b8614377

+3 -2
+3 -2
sound/soc/codecs/cs35l56-shared.c
··· 658 658 return ret; 659 659 } 660 660 661 - unique_id = pte.lot[2] | (pte.lot[1] << 8) | (pte.lot[0] << 16); 661 + unique_id = (u32)pte.lot[2] | ((u32)pte.lot[1] << 8) | ((u32)pte.lot[0] << 16); 662 662 unique_id <<= 32; 663 - unique_id |= pte.x | (pte.y << 8) | (pte.wafer_id << 16) | (pte.dvs << 24); 663 + unique_id |= (u32)pte.x | ((u32)pte.y << 8) | ((u32)pte.wafer_id << 16) | 664 + ((u32)pte.dvs << 24); 664 665 665 666 dev_dbg(cs35l56_base->dev, "UniqueID = %#llx\n", unique_id); 666 667