]> git.baikalelectronics.ru Git - kernel.git/commit
raid5: fix memory leak of bio integrity data
authorShaohua Li <shli@fb.com>
Tue, 23 Aug 2016 04:14:01 +0000 (21:14 -0700)
committerShaohua Li <shli@fb.com>
Wed, 24 Aug 2016 17:21:52 +0000 (10:21 -0700)
commit5cae949494f51ab900586be41d3ac8cd211819ad
tree928efbe6ba6efef4e84eed37103038015770614a
parenta7db8962773dd27c6bb0a280a921055c784ea1b5
raid5: fix memory leak of bio integrity data

Yi reported a memory leak of raid5 with DIF/DIX enabled disks. raid5
doesn't alloc/free bio, instead it reuses bios. There are two issues in
current code:
1. the code calls bio_init (from
init_stripe->raid5_build_block->bio_init) then bio_reset (ops_run_io).
The bio is reused, so likely there is integrity data attached. bio_init
will clear a pointer to integrity data and makes bio_reset can't release
the data
2. bio_reset is called before dispatching bio. After bio is finished,
it's possible we don't free bio's integrity data (eg, we don't call
bio_reset again)
Both issues will cause memory leak. The patch moves bio_init to stripe
creation and bio_reset to bio end io. This will fix the two issues.

Reported-by: Yi Zhang <yizhan@redhat.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5.c