bcache: avoid oversize memory allocation by small stripe_size
[platform/kernel/linux-starfive.git] / drivers / md / bcache / super.c
index 0ae2b36..93791e4 100644 (file)
@@ -905,6 +905,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
 
        if (!d->stripe_size)
                d->stripe_size = 1 << 31;
+       else if (d->stripe_size < BCH_MIN_STRIPE_SZ)
+               d->stripe_size = roundup(BCH_MIN_STRIPE_SZ, d->stripe_size);
 
        n = DIV_ROUND_UP_ULL(sectors, d->stripe_size);
        if (!n || n > max_stripes) {