Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC08CC433EF for ; Mon, 29 Nov 2021 22:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233459AbhK2Whw (ORCPT ); Mon, 29 Nov 2021 17:37:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233468AbhK2WhX (ORCPT ); Mon, 29 Nov 2021 17:37:23 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE3EC127105 for ; Mon, 29 Nov 2021 10:05:14 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id k23so36171546lje.1 for ; Mon, 29 Nov 2021 10:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IDi3zvjd6u7ZBVvXAka/LTSyAvUkqeh+L5SnX6c8Zdk=; b=ELtQ57DjVTWJPnvASv4jZtvg9xzVjpRXdLK6WadVUiqQO2Tejx2Y4rP/jZvsvwdaGM wVK5qYNcJTRTVvihhUy6a3XfzO7ShXe3HSKg9CJ9S9TdxAt3X4+ddQNsKXsRbhOEV3Nn NeS7l4DPoqAaH0j+Gm2rrnRobzgyBp+zZRI4nhmfoSItyMTQPe6HJsrb3a8uXIO7pAUp d0pHSCno/fnC3Fp0q+W51eSWigYy/I5qIJhRZa/O1KEhI708OF8jeLET61Dg8b9kw0VH st1/mw7gEQ1NVGLv+ANo/xqXiZgR94N5ykkWzVgrrh3SWq2UdJQ1DTZyuwBI86rq3HIq HE3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IDi3zvjd6u7ZBVvXAka/LTSyAvUkqeh+L5SnX6c8Zdk=; b=s13eEEVnB+C6q0e1we0DNGtuJg7QuJNWoD554uYq+UMw4ScKmhAqIDU3IGhrQKEnTs k19DZqRQBx6AbAWDX1zg73ub9whKJyGlBAtC+4pxBR3jOh/k+vBOVMF1gKo2GGZWCI/q uiNzaMvhV87OBqMmm+1AWjJD4BWrpyPR70QUYrqGOHDi65ctaXfz7txvyuwkjDoi26fp 1UfHcfOyhQqzZ/Cykne76CbWsk72wDupz0pou1j/CyHjwxXOsaTKlihJix/jmqSUQJT3 mOq2Rdhuul7BWnM2pHLXe8wadBGINMfH1R7q+ihsAIGIbOY3vIShuRxkX4rldm3xP/GG iboA== X-Gm-Message-State: AOAM533bgtEsgKXRYVGy5/67Y1oP7BuwJh26GOoeWDkykwIJhvWI+TfN Y+9bOFojE2Pk3YI3nJ30fDaOsJePREEW5bDN8i8rfA== X-Google-Smtp-Source: ABdhPJz00rJJqhFv+eY/G4mQJbhWwtM/vfpfxJXb8qlKInsjRYgNcLli9eLdqgC5XVztKYKpkdzK0NNalzo7Gw9l8CQ= X-Received: by 2002:a2e:95d3:: with SMTP id y19mr50881703ljh.175.1638209112922; Mon, 29 Nov 2021 10:05:12 -0800 (PST) MIME-Version: 1.0 References: <20211126074904.88388-1-guangming.cao@mediatek.com> In-Reply-To: <20211126074904.88388-1-guangming.cao@mediatek.com> From: John Stultz Date: Mon, 29 Nov 2021 10:05:00 -0800 Message-ID: Subject: Re: [PATCH v4] dma-buf: system_heap: Use 'for_each_sgtable_sg' in pages free flow To: guangming.cao@mediatek.com Cc: greg@kroah.com, Brian.Starkey@arm.com, benjamin.gaignard@linaro.org, christian.koenig@amd.com, dri-devel@lists.freedesktop.org, labbott@redhat.com, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, lmark@codeaurora.org, matthias.bgg@gmail.com, robin.murphy@arm.com, stable@vger.kernel.org, sumit.semwal@linaro.org, wsd_upstream@mediatek.com, kuan-ying.lee@mediatek.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 25, 2021 at 11:48 PM wrote: > > From: Guangming > > For previous version, it uses 'sg_table.nent's to traverse sg_table in pages > free flow. > However, 'sg_table.nents' is reassigned in 'dma_map_sg', it means the number of > created entries in the DMA adderess space. > So, use 'sg_table.nents' in pages free flow will case some pages can't be freed. > > Here we should use sg_table.orig_nents to free pages memory, but use the > sgtable helper 'for each_sgtable_sg'(, instead of the previous rather common > helper 'for_each_sg' which maybe cause memory leak) is much better. > > Fixes: d963ab0f15fb0 ("dma-buf: system_heap: Allocate higher order pages if available") > Signed-off-by: Guangming > Reviewed-by: Robin Murphy > Cc: # 5.11.* Thanks so much for catching this and sending in all the revisions! Reviewed-by: John Stultz