md/raid1: free r1_bio when REQ_NOWAIT is set and read would block on retry
PATCH 1/1 md/raid1: free r1_bio when REQ_NOWAIT is set and read would block on retry
When a read is retried, raid1_read_request() may be called with a pre-allocated r1_bio. If wait_read_barrier() fails for a REQ_NOWAIT read, the bio is completed and the function returns immediately. In this case the existing r1_bio is leaked.
This fixes a leak of pre-allocated r1_bio structures for retried reads.
Fixes 5aa705039c4f ("md: raid1 add nowait support")
Reported-by sashiko-bot <[email protected]>
Signed-off-by Abd-Alrhman Masalkhi <[email protected]>
--- drivers/md/raid1.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/md/raid1.c +6 -0
@@ -1363,6 +1363,12 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,*/ if (!wait_read_barrier (conf, bio->bi_iter.bi_sector, nowait)) {bio_wouldblock_error (bio); + +if (r1bio_existed) { +set_bit (R1BIO_Returned, &r1_bio->state); +raid_end_bio_io (r1_bio); + } +return ; }
Signature · 1 line
2.43.0
Quoted 7 lines · Abd-Alrhman Masalkhi
When a read is retried,
raid1_read_request()may be called with a pre-allocatedr1_bio. Ifwait_read_barrier()fails for aREQ_NOWAITread, the bio is completed and the function returns immediately. In this case the existingr1_biois leaked.This fixes a leak of pre-allocated
r1_biostructures for retried reads.
Quoted 7 lines
Fixes 5aa705039c4f ("md: raid1 add nowait support")Reported-by sashiko-bot<[email protected]>Signed-off-by Abd-Alrhman Masalkhi<[email protected]>--- drivers/md/raid1.c | 6 ++++++ 1 file changed, 6 insertions(+)
Applied to md-7.2
Signature · 2 lines
Thanks, Kuai