Skip to contentSkip to conversation

Fix reported kmemleak

PATCH In review Shaun Tancheff 4 participants 5 messages Jun 7, 2016 – Jun 12, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix reported kmemleak

This fixes a memory leak reported by a few people in 4.7-rc1

kmemleak report after 9082e87bfbf8 ("block: remove struct bio_batch")

This patch just formalizes the one in this discussion here:
https://lkml.kernel.org/r/[email protected]

The same issue appears here:
https://lkml.kernel.org/r/[email protected]

Patch is also available at:

https://github.com/stancheff/linux.git
branch: v4.7-rc2+bio_put

Cc Christoph Hellwig <[email protected]>
cc David Drysdale <[email protected]>
Cc Xiong Zhou <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Larry Finger <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Jens Axboe <[email protected]>,

Shaun Tancheff (1):
Missing bio_put following submit_bio_wait

 block/blk-lib.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.8.1
#1 lore raw

PATCH 1/1 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")

---
 block/blk-lib.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
block/blk-lib.c +9 -3
index 23d7f30..9e29dc3 100644
@@ -113,6 +113,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 		ret = submit_bio_wait(type, bio);
 		if (ret == -EOPNOTSUPP)
 			ret = 0;
+		bio_put(bio);
 	}
 	blk_finish_plug(&plug);
 
@@ -165,8 +166,10 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
 		}
 	}
 
-	if (bio)
+	if (bio) {
 		ret = submit_bio_wait(REQ_WRITE | REQ_WRITE_SAME, bio);
+		bio_put(bio);
+	}
 	return ret != -EOPNOTSUPP ? ret : 0;
 }
 EXPORT_SYMBOL(blkdev_issue_write_same);
@@ -206,8 +209,11 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
 		}
 	}
 
-	if (bio)
-		return submit_bio_wait(WRITE, bio);
+	if (bio) {
+		ret = submit_bio_wait(WRITE, bio);
+		bio_put(bio);
+		return ret;
+	}
 	return 0;
 }
 
Signature · 1 line
2.8.1
maintainer Applied
#3 lore raw

Re: [PATCH] Missing bio_put following submit_bio_wait

In reply to Shaun Tancheff
Quoted 10 lines · Shaun Tancheff

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")

Thanks, applied.

Signature · 1 line
Jens Axboe
#4 lore raw
In reply to Shaun Tancheff

Hi,

Quoted 12 lines · Shaun Tancheff

This fixes a memory leak reported by a few people in 4.7-rc1

kmemleak report after 9082e87bfbf8 ("block: remove struct bio_batch")

This patch just formalizes the one in this discussion here:
https://lkml.kernel.org/r/[email protected]

The same issue appears here:
https://lkml.kernel.org/r/[email protected]

Patch is also available at:

Quoted 7 lines

https://github.com/stancheff/linux.git
branch: v4.7-rc2+bio_put

Cc Christoph Hellwig <[email protected]>
cc David Drysdale <[email protected]>
Cc Xiong Zhou <[email protected]>

Thanks for the information!

Quoted 19 lines
Cc Stephen Rothwell <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Larry Finger <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Jens Axboe <[email protected]>,

Shaun Tancheff (1):
Missing bio_put following submit_bio_wait

 block/blk-lib.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.8.1