From nobody Sat Apr 18 12:41:54 2026 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 29D18C433EF for ; Thu, 14 Jul 2022 03:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232695AbiGNDZj (ORCPT ); Wed, 13 Jul 2022 23:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbiGNDZh (ORCPT ); Wed, 13 Jul 2022 23:25:37 -0400 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23CF4255B9 for ; Wed, 13 Jul 2022 20:25:35 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=liusong@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0VJHNBNf_1657769100; Received: from localhost(mailfrom:liusong@linux.alibaba.com fp:SMTPD_---0VJHNBNf_1657769100) by smtp.aliyun-inc.com; Thu, 14 Jul 2022 11:25:33 +0800 From: Liu Song To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc Date: Thu, 14 Jul 2022 11:25:00 +0800 Message-Id: <1657769100-66142-1-git-send-email-liusong@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liu Song In "dma_direct_alloc", the allocated memory is explicitly set to 0. If use direct alloc, we need to avoid possible duplicate memset in dma_pool_alloc. Signed-off-by: Liu Song --- mm/dmapool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/dmapool.c b/mm/dmapool.c index a7eb5d0..94f4859 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -21,6 +21,7 @@ =20 #include #include +#include #include #include #include @@ -372,7 +373,7 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_f= lags, #endif spin_unlock_irqrestore(&pool->lock, flags); =20 - if (want_init_on_alloc(mem_flags)) + if (want_init_on_alloc(mem_flags) && get_dma_ops(pool->dev)) memset(retval, 0, pool->size); =20 return retval; --=20 1.8.3.1