summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-10-04 08:01:14 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2017-01-18 21:40:32 -0900
commit025d6e3b72a7c9fc349c556467e91f86c4b75e20 (patch)
tree3b6dea6e7727f641bc07ffae24d24a093ccc94d8
parent8956db0dc6e2ba979b7a9cb55a50dd7a2302f3db (diff)
bcache: fix a divide by zero
-rw-r--r--drivers/md/bcache/alloc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index c2964b47d209..ce8b548e252b 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -938,6 +938,10 @@ static void recalc_alloc_group_weights(struct cache_set *c,
available_buckets += devs->d[i].weight;
}
+ /* avoid divide by zero... */
+ if (!available_buckets)
+ return;
+
for (i = 0; i < devs->nr_devices; i++) {
const unsigned min_weight = U32_MAX >> 4;
const unsigned max_weight = U32_MAX;