stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "regmap: Fix possible shift overflow in regmap_field_init()" has been added to the 4.0-stable tree
@ 2015-07-17  3:14 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2015-07-17  3:14 UTC (permalink / raw)
  To: maxime.coquelin, broonie, gregkh; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    regmap: Fix possible shift overflow in regmap_field_init()

to the 4.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     regmap-fix-possible-shift-overflow-in-regmap_field_init.patch
and it can be found in the queue-4.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 921cc29473a0d7c109105c1876ddb432f4a4be7d Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin@st.com>
Date: Tue, 16 Jun 2015 13:53:19 +0200
Subject: regmap: Fix possible shift overflow in regmap_field_init()

From: Maxime Coquelin <maxime.coquelin@st.com>

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 |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -945,11 +945,10 @@ EXPORT_SYMBOL_GPL(devm_regmap_init);
 static void regmap_field_init(struct regmap_field *rm_field,
 	struct regmap *regmap, struct reg_field reg_field)
 {
-	int field_bits = reg_field.msb - reg_field.lsb + 1;
 	rm_field->regmap = regmap;
 	rm_field->reg = reg_field.reg;
 	rm_field->shift = reg_field.lsb;
-	rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb);
+	rm_field->mask = GENMASK(reg_field.msb, reg_field.lsb);
 	rm_field->id_size = reg_field.id_size;
 	rm_field->id_offset = reg_field.id_offset;
 }


Patches currently in stable-queue which might be from maxime.coquelin@st.com are

queue-4.0/regmap-fix-possible-shift-overflow-in-regmap_field_init.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-17  3:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-17  3:14 Patch "regmap: Fix possible shift overflow in regmap_field_init()" has been added to the 4.0-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).