ASoC: rt1011: fix KASAN out-of-bounds bug in find_next_bit()
authorFred Oh <fred.oh@linux.intel.com>
Mon, 22 Jun 2020 15:13:48 +0000 (10:13 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 23 Jun 2020 11:54:11 +0000 (12:54 +0100)
commitee8a41cd30a99b39bd5d46280cc778e275cd2390
tree2bd42b6fca5aad106f490bd24b0beecb25483da6
parentb1647f9f4f27824a689f774014bc33728b4fe7ec
ASoC: rt1011: fix KASAN out-of-bounds bug in find_next_bit()

KASAN throws the following warning in rt1011.c:
[ 170.777603] BUG: KASAN: stack-out-of-bounds in _find_next_bit.constprop.0+0x3e/0xf0

find_next_bit() relies on unsigned long pointer arguments, but this driver
uses a type cast that generates the KASAN warning. Replace find_next_bit()
and find_last_bit() with __ffs() and __fls() to pass the value and avoid
casting pointers to make the warning go away.

Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Link: https://lore.kernel.org/r/20200622151348.28063-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt1011.c