summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;