From patchwork Tue Jun 7 16:32:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaun Tancheff X-Patchwork-Id: 9161985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B03D60572 for ; Tue, 7 Jun 2016 16:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C98125819 for ; Tue, 7 Jun 2016 16:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11433281F9; Tue, 7 Jun 2016 16:32:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, URIBL_BLACK autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A3FA125819 for ; Tue, 7 Jun 2016 16:32:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 09B051A1F48; Tue, 7 Jun 2016 09:33:15 -0700 (PDT) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from dsmdc-mail-smtp.mcomdc.com (smtp78.mediacombb.net [68.66.77.78]) by ml01.01.org (Postfix) with ESMTP id A85491A1F48 for ; Tue, 7 Jun 2016 09:33:13 -0700 (PDT) Received: from helios ([173.23.250.243]) by njtocomv03.mcomdc.com with bizsmtp id 3sYK1t00M5FqEsV01sYKMN; Tue, 07 Jun 2016 12:32:23 -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 Received: from shaun by helios with local (Exim 4.87) (envelope-from ) id 1bAJvP-0003Se-9f; Tue, 07 Jun 2016 11:32:19 -0500 From: Shaun Tancheff To: linux-block@vger.kernel.org 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> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: axboe@kernel.dk, Stephen Rothwell , Shaun Tancheff , linux-nvdimm@ml01.01.org, LKML , David Drysdale , Jens Axboe , linux-next@vger.kernel.org, Catalin Marinas , bart.vanassche@sandisk.com, Shaun Tancheff , Christoph Hellwig , Larry Finger MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Christoph Hellwig --- 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; }