diff options
author | Shaun Tancheff <shaun@tancheff.com> | 2016-06-07 12:32:13 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-06-07 12:47:48 -0400 |
commit | 05bd92dddc595d74ea645e793c1f3bd4b1fc251a (patch) | |
tree | 4495eb3d9de4c5d24fa38fb972c2038079d797f5 | |
parent | 87c279e613f848c691111b29d49de8df3f4f56da (diff) |
block: missing bio_put following submit_bio_wait
submit_bio_wait() gives the caller an opportunity to examine
struct bio and so expects the caller to issue the put_bio()
This fixes a memory leak reported by a few people in 4.7-rc2
kmemleak report after 9082e87bfbf8 ("block: remove struct bio_batch")
Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Larry Finger@lwfinger.net
Tested-by: David Drysdale <drysdale@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | block/blk-lib.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/block/blk-lib.c b/block/blk-lib.c index 23d7f301a196..9e29dc351695 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c | |||
@@ -113,6 +113,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
113 | ret = submit_bio_wait(type, bio); | 113 | ret = submit_bio_wait(type, bio); |
114 | if (ret == -EOPNOTSUPP) | 114 | if (ret == -EOPNOTSUPP) |
115 | ret = 0; | 115 | ret = 0; |
116 | bio_put(bio); | ||
116 | } | 117 | } |
117 | blk_finish_plug(&plug); | 118 | blk_finish_plug(&plug); |
118 | 119 | ||
@@ -165,8 +166,10 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, | |||
165 | } | 166 | } |
166 | } | 167 | } |
167 | 168 | ||
168 | if (bio) | 169 | if (bio) { |
169 | ret = submit_bio_wait(REQ_WRITE | REQ_WRITE_SAME, bio); | 170 | ret = submit_bio_wait(REQ_WRITE | REQ_WRITE_SAME, bio); |
171 | bio_put(bio); | ||
172 | } | ||
170 | return ret != -EOPNOTSUPP ? ret : 0; | 173 | return ret != -EOPNOTSUPP ? ret : 0; |
171 | } | 174 | } |
172 | EXPORT_SYMBOL(blkdev_issue_write_same); | 175 | EXPORT_SYMBOL(blkdev_issue_write_same); |
@@ -206,8 +209,11 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | |||
206 | } | 209 | } |
207 | } | 210 | } |
208 | 211 | ||
209 | if (bio) | 212 | if (bio) { |
210 | return submit_bio_wait(WRITE, bio); | 213 | ret = submit_bio_wait(WRITE, bio); |
214 | bio_put(bio); | ||
215 | return ret; | ||
216 | } | ||
211 | return 0; | 217 | return 0; |
212 | } | 218 | } |
213 | 219 | ||