md/raid10: fix memory leak when reshaping a RAID10.
authorNeilBrown <neilb@suse.de>
Mon, 18 Aug 2014 03:56:38 +0000 (13:56 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 19 Aug 2014 07:20:27 +0000 (17:20 +1000)
raid10 reshape clears unwanted bits from a bio->bi_flags using
a method which, while clumsy, worked until 3.10 when BIO_OWNS_VEC
was added.
Since then it clears that bit but shouldn't.  This results in a
memory leak.

So change to used the approved method of clearing unwanted bits.

As this causes a memory leak which can consume all of memory
the fix is suitable for -stable.

Fixes: a38352e0ac02dbbd4fa464dc22d1352b5fbd06fd
Cc: stable@vger.kernel.org (v3.10+)
Reported-by: mdraid.pkoch@dfgh.net (Peter Koch)
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid10.c

index b08c18871323c904f3964e9c8b650366ad2979ef..d9073a10f2f2c3b941799328112d1f30b139805e 100644 (file)
@@ -4410,7 +4410,7 @@ read_more:
        read_bio->bi_private = r10_bio;
        read_bio->bi_end_io = end_sync_read;
        read_bio->bi_rw = READ;
-       read_bio->bi_flags &= ~(BIO_POOL_MASK - 1);
+       read_bio->bi_flags &= (~0UL << BIO_RESET_BITS);
        read_bio->bi_flags |= 1 << BIO_UPTODATE;
        read_bio->bi_vcnt = 0;
        read_bio->bi_iter.bi_size = 0;