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

    regmap: prevent division by zero in rbtree_show

to the 3.3-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-prevent-division-by-zero-in-rbtree_show.patch
and it can be found in the queue-3.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From c04c1b9ee8f30c7a3a25e20e406247003f634ebe Mon Sep 17 00:00:00 2001
From: Stephen Warren <[email protected]>
Date: Wed, 4 Apr 2012 15:48:33 -0600
Subject: regmap: prevent division by zero in rbtree_show

From: Stephen Warren <[email protected]>

commit c04c1b9ee8f30c7a3a25e20e406247003f634ebe upstream.

If there are no nodes in the cache, nodes will be 0, so calculating
"registers / nodes" will cause division by zero.

Signed-off-by: Stephen Warren <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 drivers/base/regmap/regcache-rbtree.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -137,6 +137,7 @@ static int rbtree_show(struct seq_file *
        unsigned int base, top;
        int nodes = 0;
        int registers = 0;
+       int average;
 
        mutex_lock(&map->lock);
 
@@ -151,8 +152,13 @@ static int rbtree_show(struct seq_file *
                registers += top - base + 1;
        }
 
+       if (nodes)
+               average = registers / nodes;
+       else
+               average = 0;
+
        seq_printf(s, "%d nodes, %d registers, average %d registers\n",
-                  nodes, registers, registers / nodes);
+                  nodes, registers, average);
 
        mutex_unlock(&map->lock);
 


Patches currently in stable-queue which might be from [email protected] are

queue-3.3/regmap-prevent-division-by-zero-in-rbtree_show.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to