linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix reported kmemleak
@ 2016-06-07 16:23 Shaun Tancheff
  2016-06-07 16:32 ` [PATCH] Missing bio_put following submit_bio_wait Shaun Tancheff
  2016-06-12 10:29 ` [PATCH] Fix reported kmemleak Xiong Zhou
  0 siblings, 2 replies; 5+ messages in thread
From: Shaun Tancheff @ 2016-06-07 16:23 UTC (permalink / raw)
  To: linux-block
  Cc: Shaun Tancheff, Christoph Hellwig, axboe, David Drysdale,
	Xiong Zhou, Stephen Rothwell, linux-next, linux-nvdimm,
	Larry Finger, Catalin Marinas, LKML, Jens Axboe, bart.vanassche

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/20160606112620.GA29910@e104818-lin.cambridge.arm.com

The same issue appears here:
https://lkml.kernel.org/r/20160607102651.GA6480@dhcp12-144.nay.redhat.com

Patch is also available at:

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

Cc: Christoph Hellwig <hch@lst.de>
Cc: axboe@kernel.dk
cc: David Drysdale <drysdale@google.com>
Cc: Xiong Zhou <xzhou@redhat.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: linux-next@vger.kernel.org
Cc: linux-nvdimm@ml01.01.org
Cc: Christoph Hellwig <hch@lst.de>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Cc: Jens Axboe <axboe@fb.com>,
Cc: bart.vanassche@sandisk.com

Shaun Tancheff (1):
  Missing bio_put following submit_bio_wait

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

-- 
2.8.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Missing bio_put following submit_bio_wait
  2016-06-07 16:23 [PATCH] Fix reported kmemleak Shaun Tancheff
@ 2016-06-07 16:32 ` Shaun Tancheff
  2016-06-07 16:46   ` Christoph Hellwig
  2016-06-07 16:48   ` Jens Axboe
  2016-06-12 10:29 ` [PATCH] Fix reported kmemleak Xiong Zhou
  1 sibling, 2 replies; 5+ messages in thread
From: Shaun Tancheff @ 2016-06-07 16:32 UTC (permalink / raw)
  To: linux-block
  Cc: Christoph Hellwig, axboe, David Drysdale, Xiong Zhou,
	Stephen Rothwell, linux-next, linux-nvdimm, Larry Finger,
	Catalin Marinas, LKML, Jens Axboe, bart.vanassche,
	Shaun Tancheff, 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")

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>
---
 block/blk-lib.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 23d7f30..9e29dc3 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,
 		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;
 }
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Missing bio_put following submit_bio_wait
  2016-06-07 16:32 ` [PATCH] Missing bio_put following submit_bio_wait Shaun Tancheff
@ 2016-06-07 16:46   ` Christoph Hellwig
  2016-06-07 16:48   ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2016-06-07 16:46 UTC (permalink / raw)
  To: Shaun Tancheff
  Cc: linux-block, Christoph Hellwig, axboe, David Drysdale,
	Xiong Zhou, Stephen Rothwell, linux-next, linux-nvdimm,
	Larry Finger, Catalin Marinas, LKML, Jens Axboe, bart.vanassche,
	Shaun Tancheff

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Missing bio_put following submit_bio_wait
  2016-06-07 16:32 ` [PATCH] Missing bio_put following submit_bio_wait Shaun Tancheff
  2016-06-07 16:46   ` Christoph Hellwig
@ 2016-06-07 16:48   ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2016-06-07 16:48 UTC (permalink / raw)
  To: Shaun Tancheff, linux-block
  Cc: Christoph Hellwig, David Drysdale, Xiong Zhou, Stephen Rothwell,
	linux-next, linux-nvdimm, Larry Finger, Catalin Marinas, LKML,
	Jens Axboe, bart.vanassche, Shaun Tancheff

On 06/07/2016 10:32 AM, Shaun Tancheff wrote:
> 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>

Thanks, applied.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix reported kmemleak
  2016-06-07 16:23 [PATCH] Fix reported kmemleak Shaun Tancheff
  2016-06-07 16:32 ` [PATCH] Missing bio_put following submit_bio_wait Shaun Tancheff
@ 2016-06-12 10:29 ` Xiong Zhou
  1 sibling, 0 replies; 5+ messages in thread
From: Xiong Zhou @ 2016-06-12 10:29 UTC (permalink / raw)
  To: Shaun Tancheff
  Cc: linux-block, Christoph Hellwig, axboe, David Drysdale,
	Xiong Zhou, Stephen Rothwell, linux-next, linux-nvdimm,
	Larry Finger, Catalin Marinas, LKML, Jens Axboe, bart.vanassche

Hi,

On Tue, Jun 07, 2016 at 11:23:30AM -0500, Shaun Tancheff wrote:
> 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/20160606112620.GA29910@e104818-lin.cambridge.arm.com
> 
> The same issue appears here:
> https://lkml.kernel.org/r/20160607102651.GA6480@dhcp12-144.nay.redhat.com
> 
> Patch is also available at:
> 
> https://github.com/stancheff/linux.git
> branch: v4.7-rc2+bio_put
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: axboe@kernel.dk
> cc: David Drysdale <drysdale@google.com>
> Cc: Xiong Zhou <xzhou@redhat.com>

Thanks for the information!

> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: linux-next@vger.kernel.org
> Cc: linux-nvdimm@ml01.01.org
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: LKML <linux-kernel@vger.kernel.org>,
> Cc: Jens Axboe <axboe@fb.com>,
> Cc: bart.vanassche@sandisk.com
> 
> Shaun Tancheff (1):
>   Missing bio_put following submit_bio_wait
> 
>  block/blk-lib.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> -- 
> 2.8.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-12 10:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 16:23 [PATCH] Fix reported kmemleak Shaun Tancheff
2016-06-07 16:32 ` [PATCH] Missing bio_put following submit_bio_wait Shaun Tancheff
2016-06-07 16:46   ` Christoph Hellwig
2016-06-07 16:48   ` Jens Axboe
2016-06-12 10:29 ` [PATCH] Fix reported kmemleak Xiong Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).