From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755475AbcFGOS1 (ORCPT ); Tue, 7 Jun 2016 10:18:27 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34251 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752132AbcFGOSZ (ORCPT ); Tue, 7 Jun 2016 10:18:25 -0400 Subject: Re: kmemleak report after 9082e87bfbf8 ("block: remove struct bio_batch") To: Catalin Marinas , Shaun Tancheff References: <20160606112620.GA29910@e104818-lin.cambridge.arm.com> <20160606141334.GA6579@lst.de> <20160606161245.GC29910@e104818-lin.cambridge.arm.com> <20160607093937.GA7122@localhost> Cc: Christoph Hellwig , linux-block@vger.kernel.org, LKML , Jens Axboe , bart.vanassche@sandisk.com, drysdale@google.com From: Larry Finger Message-ID: <5756D7AD.1000602@lwfinger.net> Date: Tue, 7 Jun 2016 09:18:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <20160607093937.GA7122@localhost> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/07/2016 04:39 AM, Catalin Marinas wrote: > On Mon, Jun 06, 2016 at 12:09:49PM -0500, Shaun Tancheff wrote: >> I'm pretty sure it is missing a bio_put() after submit_bio_wait(). >> >> Please excuse the hack-y patch but I think you need to do something >> like this ... >> (Note tabs eaten by gmail). >> >> 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; >> } > > This patch appears to fix the memory leak on my machine. > > Tested-by: Catalin Marinas The patch appears to work here as well. Tested-by: Larry Finger@lwfinger.net Thanks, Larry