Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2562894pxk; Sun, 20 Sep 2020 08:31:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV7wJa+wJBLP7DLbJgNQJUIhQXeh83Ixj6Uzl8dm2S00dk5T1eGCjlJ+Rg07gD4bcEJ+J9 X-Received: by 2002:a17:906:1f42:: with SMTP id d2mr44672881ejk.407.1600615865035; Sun, 20 Sep 2020 08:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600615865; cv=none; d=google.com; s=arc-20160816; b=qHOpaHq1TBBaSTVt7AVYl7AQRKgysX+vsIOfT3GF9Yw18fW4LsjaClC8ZScuZHy2uT hpWQmdf3uL9x2WIOF8akb9Z+MVcOi8Do2RXSpNnExteOaDgqS16kaVqm+Wv+9s19vEaC DBQYW0nKvW24UGExTPId9rh4MPOVCQ1epjI6VrjwliUb4O8BjS4FxtzDHZGDfTggdZMM 2FVjma+374ZKD8Qhq11+GBtfcbBml3ZaiBsZPydrBylEIAx2EhXQISsiUWXiRNuau6Nv CAOlm+rt4ZJ3kWa+SzIThQaQe1atOCjTof7QD6h5ChVWt2SSd1/s8qi+oENPjsglN86p alug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject; bh=IaFHtmDM2KcL9E++emC0UGl3lJxhdOO/H9KX6vV34y8=; b=1C7RqnawhAenQnYkU9DR8Cbd+PlIqaa3lMnDxZHhYXFqD4nxZqe5JWl3xcM1FTMZWu ejea/xNI5K2bIPqrfV2DrQNCoFvXyRiuy6fY9sCB57/+r5aiZpNrHx13CYDzqac7detq f38V/cslxFPotinrfauuvNZi/eZEeaU3slWCFi3O1IgfpeNurDFYJ3ktV+NODiGXS+so 0Ct37Jrojhq/pnB6iQpJDXmsGPJU9fsXBjp0FUh22VVrIczhDHPaiK6Vl3mCjwNTbDTA HpUDPjZ0c0dNQ4fRjUeaPEMFgsDZYQxc/3RYyCFKawKNTwOPESgEo3kbr8l3txZetZcj avuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot3si6338380ejb.103.2020.09.20.08.30.41; Sun, 20 Sep 2020 08:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbgITP3n (ORCPT + 99 others); Sun, 20 Sep 2020 11:29:43 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44849 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbgITP3m (ORCPT ); Sun, 20 Sep 2020 11:29:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id 7so6557377pgm.11; Sun, 20 Sep 2020 08:29:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=IaFHtmDM2KcL9E++emC0UGl3lJxhdOO/H9KX6vV34y8=; b=CaOmbZ1jxftBIc7SMkO6hrZ6jGv+8Wk6iUTjgUszutJASGS4ZA+Zn/8ROdjo6MRV39 Oo8msbPKCS9Fb9j6e4r/0eZRpeVlTuQ0eGvZ9TSUJ7nk3/C5pnk42cPTeC9i9gnitAy8 HnJ3pSjxhfuS3FsJCWZTZTkrVO/cSVvlP4tIADBR9p4jWBzqXYkFLMPsNLj4PkcrHBSY 7lS+Dt5cBaP9uU8f1aoo+3uL64s6sP/Cmok+XDdtVt5etAW3YnNEs8xDog0a5xanfoYO 1FhJT7WGZ9U+sx/H48mOvROtew/EiZu9Olcwui/JKm2MvbCjxu5rljDIBtpsSXb39ckQ RulQ== X-Gm-Message-State: AOAM530hFxtBIK0yYsmuxWgDHbJ9o+t9v/az443vPwlnJsUVaXC2up6M bFiZRXmCbtfkjHlGVhUmMUHHHVUQE/0= X-Received: by 2002:a65:5cc2:: with SMTP id b2mr34134614pgt.124.1600615781747; Sun, 20 Sep 2020 08:29:41 -0700 (PDT) Received: from ?IPv6:2601:647:4000:d7:7b71:dd79:a872:b92c? ([2601:647:4000:d7:7b71:dd79:a872:b92c]) by smtp.gmail.com with ESMTPSA id bx18sm8233353pjb.6.2020.09.20.08.29.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 20 Sep 2020 08:29:40 -0700 (PDT) Subject: Re: [PATCH] sgl_alloc_order: memory leak To: Douglas Gilbert , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, axboe@kernel.dk References: <20200920053607.35002-1-dgilbert@interlog.com> From: Bart Van Assche Autocrypt: addr=bvanassche@acm.org; prefer-encrypt=mutual; keydata= mQENBFSOu4oBCADcRWxVUvkkvRmmwTwIjIJvZOu6wNm+dz5AF4z0FHW2KNZL3oheO3P8UZWr LQOrCfRcK8e/sIs2Y2D3Lg/SL7qqbMehGEYcJptu6mKkywBfoYbtBkVoJ/jQsi2H0vBiiCOy fmxMHIPcYxaJdXxrOG2UO4B60Y/BzE6OrPDT44w4cZA9DH5xialliWU447Bts8TJNa3lZKS1 AvW1ZklbvJfAJJAwzDih35LxU2fcWbmhPa7EO2DCv/LM1B10GBB/oQB5kvlq4aA2PSIWkqz4 3SI5kCPSsygD6wKnbRsvNn2mIACva6VHdm62A7xel5dJRfpQ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1np0z3/RDnoVyfmfbbL1DY7zf2hYXLLzsJR mSsED/1nlJ9Oq5fALdNEPgDyPUerqHxcmIub+pF0AzJoYHK5punqpqfGmqPbjxrJLPJfHVKy goMj5DlBMoYqEgpbwdUYkH6QdizJJCur4icy8GUNbisFYABeoJ91pnD4IGei3MTdvINSZI5e Message-ID: <6376bc21-0542-bdc5-fa30-4a76ab3cbc67@acm.org> Date: Sun, 20 Sep 2020 08:29:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200920053607.35002-1-dgilbert@interlog.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-09-19 22:36, Douglas Gilbert wrote: > Noticed that when sgl_alloc_order() failed with order > 0 that > free memory on my machine shrank. That function shouldn't call > sgl_free() on its error path since that is only correct when > order==0 . > > Signed-off-by: Douglas Gilbert > --- > lib/scatterlist.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/scatterlist.c b/lib/scatterlist.c > index 5d63a8857f36..c448642e0f78 100644 > --- a/lib/scatterlist.c > +++ b/lib/scatterlist.c > @@ -514,7 +514,7 @@ struct scatterlist *sgl_alloc_order(unsigned long long length, > elem_len = min_t(u64, length, PAGE_SIZE << order); > page = alloc_pages(gfp, order); > if (!page) { > - sgl_free(sgl); > + sgl_free_order(sgl, order); > return NULL; > } Reviewed-by: Bart Van Assche