Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1141418ioo; Sun, 22 May 2022 05:09:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl7ZEym2CHKS+hRz9Y4VoT7ebJ51wFzGB8DS67LZV4gGa7UYO5yE/MXa4uptKVIcH+RzY4 X-Received: by 2002:a63:1a1d:0:b0:3f5:eb02:b6b4 with SMTP id a29-20020a631a1d000000b003f5eb02b6b4mr16529445pga.343.1653221341943; Sun, 22 May 2022 05:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653221341; cv=none; d=google.com; s=arc-20160816; b=tux/VIMHc91a/7ahlRsmoOqQWjBtDf+FhwvTI6FoF9RFuz1LtfH/q3901M0L6jJej/ 7WX8HE/hVynjzsA7UrmZEc9b6jukgq2OKzh/uVjAXoZFXthEqcQeEvG7n8yQ/bF9vw0J H/GrY4bMVH6kJcstjG7J1XY+KxXIEv/O4pofTjaV06yJJ1G0JcqPQWYRVYC+J1EEuJQE VpsBHAqiCjDK9Df1Fj3JaJNfk4OWzc/udtuLtISLGW/7nxiQ/MiWqCHUZkOUxCS33AWh 2Q/FBi0xFhkTarfIEzIHETlEcToublE4LstujqABQNc6vxAmXzheNPGJPgLBJ4WyL9PK bVAg== 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=6JL3MjbglmHXxAeLlCQsHXg8AOfIue2X95BkrWaClMA=; b=CdwgB29crKXvGBoSvskUOqCYVNFutc84wmOKBfVdeIyKzREzHmgae0WnEV0ltELyLg IKEB/410iaMydQmBsZQV3q+s8k/pdATkv+eFfK2fWh/k5VxDFbbltwN8q4idRKtPjYh4 YL/R94CFE6ZFOazUpylUyun7s2/MeJqMchkfZ35oi6iTEvIalNnVu+Q/HrcTUnjocYxV RFo6B+rmfgJsomDQKsYhYJdN8eXeCf0qXIDZSmGAXoqbsvI9YiZi4KdusNJjpyNQiji0 jAWWY0czuJT7ldkdPQNTyCTeUUqt1EHjdAMVsjh4yzyRJB2XrF75yI+oi4Cro0uDdPjC Cvfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a170902d54a00b00153b2d1657fsi6508339plf.391.2022.05.22.05.08.49; Sun, 22 May 2022 05:09:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344214AbiEUR0g (ORCPT + 99 others); Sat, 21 May 2022 13:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244601AbiEUR00 (ORCPT ); Sat, 21 May 2022 13:26:26 -0400 Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr [80.12.242.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C43752127F for ; Sat, 21 May 2022 10:26:21 -0700 (PDT) Received: from pop-os.home ([86.243.180.246]) by smtp.orange.fr with ESMTPA id sSrpnEgTlOXCysSrpnRCQC; Sat, 21 May 2022 19:26:19 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 21 May 2022 19:26:19 +0200 X-ME-IP: 86.243.180.246 From: Christophe JAILLET To: dan.carpenter@oracle.com, Peter Ujfalusi , Vinod Koul , Joel Fernandes , Sekhar Nori Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Peter Ujfalusi , dmaengine@vger.kernel.org Subject: [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw() Date: Sat, 21 May 2022 19:26:15 +0200 Message-Id: <8c95c485be294e64457606089a2a56e68e2ebd1a.1653153959.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the 'queue_priority_mapping' is not provided, we need to allocate the correct amount of memory. Each entry takes 2 s8, so actually less memory than needed is allocated. Update the size of each entry when the memory is devm_kcalloc'ed. Fixes: 6d10c3950bf4 ("ARM: edma: Get IP configuration from HW (number of channels, tc, etc)") Signed-off-by: Christophe JAILLET --- Note that the devm_kcalloc() in edma_xbar_event_map() looks also spurious. However, this looks fine to me because of the 'nelm >>= 1;' before the 'for' loop. --- drivers/dma/ti/edma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c index 3ea8ef7f57df..f313e2cf542c 100644 --- a/drivers/dma/ti/edma.c +++ b/drivers/dma/ti/edma.c @@ -2121,7 +2121,7 @@ static int edma_setup_from_hw(struct device *dev, struct edma_soc_info *pdata, * priority. So Q0 is the highest priority queue and the last queue has * the lowest priority. */ - queue_priority_map = devm_kcalloc(dev, ecc->num_tc + 1, sizeof(s8), + queue_priority_map = devm_kcalloc(dev, ecc->num_tc + 1, sizeof(s8) * 2, GFP_KERNEL); if (!queue_priority_map) return -ENOMEM; -- 2.34.1