]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
regmap: Fix possible shift overflow in regmap_field_init()
authorMaxime Coquelin <maxime.coquelin@st.com>
Tue, 16 Jun 2015 11:53:19 +0000 (13:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Jul 2015 17:10:13 +0000 (10:10 -0700)
commita615d483d22b2c3f0b413d74b6f3e6e4f2726acd
tree2d4d3becb443f9ddc8bfbb305db5288746b630a0
parent6f6b43216e3f1a9c3254f475b5446892d954852d
regmap: Fix possible shift overflow in regmap_field_init()

commit 921cc29473a0d7c109105c1876ddb432f4a4be7d upstream.

The way the mask is generated in regmap_field_init() is wrong.
Indeed, a field initialized with msb = 31 and lsb = 0 provokes a shift
overflow while calculating the mask field.

On some 32 bits architectures, such as x86, the generated mask is 0,
instead of the expected 0xffffffff.

This patch uses GENMASK() to fix the problem, as this macro is already safe
regarding shift overflow.

Signed-off-by: Maxime Coquelin <maxime.coquelin@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/regmap/regmap.c