Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2320418pxk; Sat, 19 Sep 2020 22:48:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfsAocdI90jHsIDRe55gBydeNAIieZFbM725oU20UduIikMfnGvPNLyXR8ds9aqaJwZ0iJ X-Received: by 2002:a50:f1cf:: with SMTP id y15mr47329090edl.204.1600580929465; Sat, 19 Sep 2020 22:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600580929; cv=none; d=google.com; s=arc-20160816; b=sTp/tKBLjnoL9U1d1qQGSZMY3jENiMiS/FQ3ISc/3RBu+jkmr5u5A7wlU4dr1Ui6jC soz9E19P6GOMbP2Ym6Or+rPB6jaIC/RjIs3JySrkMcw/zlz232VlBKdJN0czdGsGVrL0 uVl8jondV/9gTEPSqoopSvF+yEWD1bmdciGZv8gLZ8d7zTgRog9EPj9NfGGP2Y8HteXE A/ogYlr7GCUWk2yPCTYhqJYVrbFrGCPfGbYAdsicmGyYIstY94pL81XGPHexSXdrXtsW NrUxT67LifKU2xqEYIpiG/kbP5ub77SNFQVKjGDkTDT/8IxtQ981B1gXAF34i9jL+hyN sNdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=gTq1qtPSNICtErAg2+RFeWoblSYLp9QJnUsVXMQza0E=; b=CnGVivlmSbSwwzRNfX/vI6dsMGNoCMQi7Nt4I/2YBnell3YVp9mz0hzV4vuBi7pw1a JTf4XatGx+4aMf5nu3ORFC9AUkgFnEP4hrFNBFW/w0AN4XJrgZJajv2GvkbHqEYhMRFE Y/P0H3tnurXkkc95dX2wSlKQAW3PoxgIgv1oBbwRR6EOkr2ze1afh2s4Fv46dKypy7we 3lEaieb9NpfeMKMEFXuLBb2awlMHXEpLml4AHWw/ESswjLVAgFHiCZsaCscceme0jIPT gTEcd5hRDwy328gHBfE0qzYzt2YnJqKSRc7JUTqdvuyuopi7Z3+u486337E6jMhdCxRS RKsw== 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 n19si5484997edq.82.2020.09.19.22.48.14; Sat, 19 Sep 2020 22:48:49 -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 S1726247AbgITFp6 (ORCPT + 99 others); Sun, 20 Sep 2020 01:45:58 -0400 Received: from smtp.infotech.no ([82.134.31.41]:43396 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgITFp6 (ORCPT ); Sun, 20 Sep 2020 01:45:58 -0400 X-Greylist: delayed 578 seconds by postgrey-1.27 at vger.kernel.org; Sun, 20 Sep 2020 01:45:57 EDT Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 62DC820419A; Sun, 20 Sep 2020 07:36:17 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QmwB39jA3PkQ; Sun, 20 Sep 2020 07:36:11 +0200 (CEST) Received: from xtwo70.bingwo.ca (host-45-78-251-166.dyn.295.ca [45.78.251.166]) by smtp.infotech.no (Postfix) with ESMTPA id D6E3720417C; Sun, 20 Sep 2020 07:36:10 +0200 (CEST) From: Douglas Gilbert To: linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, axboe@kernel.dk Subject: [PATCH] sgl_alloc_order: memory leak Date: Sun, 20 Sep 2020 01:36:07 -0400 Message-Id: <20200920053607.35002-1-dgilbert@interlog.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.25.1