From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161762AbcFGQdH (ORCPT ); Tue, 7 Jun 2016 12:33:07 -0400 Received: from smtp78.mediacombb.net ([68.66.77.78]:60621 "EHLO dsmdc-mail-smtp.mcomdc.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932751AbcFGQdF (ORCPT ); Tue, 7 Jun 2016 12:33:05 -0400 X-Outbound-Route: TO X-Authenticated-Sender: shaun@helios.aeonazure.com X-Authority-Analysis: v=2.1 cv=Yq2BRuoX c=1 sm=1 tr=0 a=OCiMecrhrNRzvyrd/uXHhg==:117 a=OCiMecrhrNRzvyrd/uXHhg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=pD_ry4oyNxEA:10 a=3go8odswAAAA:8 a=7CQSdrXTAAAA:8 a=yQdBAQUQAAAA:8 a=1XWaLZrsAAAA:8 a=arPX7R5VgojJaqbuIgEA:9 a=WCphLhRDQySbTNkkd-8K:22 a=a-qgeE7W1pNrGK8U0ZQC:22 a=SzazLyfi1tnkUD6oumHU:22 a=nJcEw6yWrPvoIXZ49MH8:22 X-Authenticated-Sender: shaun@helios.aeonazure.com From: Shaun Tancheff To: linux-block@vger.kernel.org Cc: Christoph Hellwig , axboe@kernel.dk, David Drysdale , Xiong Zhou , Stephen Rothwell , linux-next@vger.kernel.org, linux-nvdimm@ml01.01.org, Larry Finger , Catalin Marinas , LKML , Jens Axboe , bart.vanassche@sandisk.com, Shaun Tancheff , Shaun Tancheff Subject: [PATCH] Missing bio_put following submit_bio_wait Date: Tue, 7 Jun 2016 11:32:13 -0500 Message-Id: <1465317133-13266-1-git-send-email-shaun@tancheff.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465316612-9649-1-git-send-email-shaun@tancheff.com> References: <1465316612-9649-1-git-send-email-shaun@tancheff.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Catalin Marinas Tested-by: Larry Finger@lwfinger.net Tested-by: David Drysdale --- 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