Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2364965ioo; Sat, 28 May 2022 11:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5/eJ/3QEgdFF24cmKKTvBb8s2HoN3EPj/BUANfK9xL0HdFInrjloJW8Rd/dJhLR7XJ1mU X-Received: by 2002:a63:d203:0:b0:3fa:91d1:3a76 with SMTP id a3-20020a63d203000000b003fa91d13a76mr23109823pgg.171.1653762193941; Sat, 28 May 2022 11:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653762193; cv=none; d=google.com; s=arc-20160816; b=ib4s5tI7CaQmahSk4i1pn1tLz2w5mV/Ens4NCfvhV491F7XQ7qOE6FYwjjfNX7GQ+r Jf/8qynm5qR1OObMa7i8y4Wy/sQAMSvaryr/O7aB3A0OHxfnI9WNnufUxmXpKJyn9Wll qhd5eVHnoqLC1ErNBNwyu4jm7YKbygCvD6Gv/cq6xqOI+T/RT4CJvd4Wz1EKFw2xsvR7 Pg0DVnsoinhD01CRoX9tXQ6t3Jis4va8sdhUAsk7abF2d7uvGYtoEKFD/qlNQdB+tVOG n/f0hW2jLHtDTNd7Rr+BI0rT/wc1N6FjhzEvuPYU9wEqLsBIw1BNo7ODYql7x7cxrO2Z AovQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=5oAgUaTnfEgHpAKSPUXMPEAI9iyGTDdCiykd49/7y/Y=; b=lC1wzdc6zLXeJwzWWeUGTtq6qH6KByCBEtNGf2NtYA05mnwdZ+px4m1E4oWC8CbLdh LE58Ozh7LOZ+mOkExHiGqzzXsZ8LLdvBCL2cZ4Ik1o0z6rCLQXNyG6sSXfUVV1pzq2kk szZQv4ilYm/HOTxRZknD60j8+YvO6mlCVdF/2y5kvaQvDlEXUf/mrJF2hb+1IXhVaGAS jWJrvUHbxgO1bVWdUuoX9qO5U2eAmv/WKQZRc/ZrQrSK6q0+ZDw3LEppVX0SORH//IbM s1uHjdxDRoLgHvkxs92uZRr8DOiFVP4jkY0H61UqDclO2FRsoHWmWetsX7PuO1rV4ZAW v9ew== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s205-20020a632cd6000000b0039d8aa59bd3si10401978pgs.612.2022.05.28.11.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 11:23:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8EF8015824; Sat, 28 May 2022 11:23:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233615AbiE1KGa (ORCPT + 99 others); Sat, 28 May 2022 06:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233631AbiE1KG2 (ORCPT ); Sat, 28 May 2022 06:06:28 -0400 Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC40338AB for ; Sat, 28 May 2022 03:06:25 -0700 (PDT) Received: from [192.168.1.18] ([90.11.191.102]) by smtp.orange.fr with ESMTPA id utKwngSjFZDzUutKwnSoQU; Sat, 28 May 2022 12:06:23 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 28 May 2022 12:06:23 +0200 X-ME-IP: 90.11.191.102 Message-ID: Date: Sat, 28 May 2022 12:06:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw() Content-Language: en-US To: =?UTF-8?Q?P=c3=a9ter_Ujfalusi?= , dan.carpenter@oracle.com, Vinod Koul , Joel Fernandes , Sekhar Nori Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Peter Ujfalusi , dmaengine@vger.kernel.org References: <8c95c485be294e64457606089a2a56e68e2ebd1a.1653153959.git.christophe.jaillet@wanadoo.fr> <6e750770-fcda-d157-21d1-872a611c3bf2@gmail.com> From: Christophe JAILLET In-Reply-To: <6e750770-fcda-d157-21d1-872a611c3bf2@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Le 28/05/2022 à 11:33, Péter Ujfalusi a écrit : > > > On 21/05/2022 20:26, Christophe JAILLET wrote: >> 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. > > This has been deprecated ever since we have moved to dma router to > handle the xbar for various TI platforms, but by the looks it kida looks > bogus in a same way. This one is correct, IIUC. There is an extra ">> 1" before the loop. (see [1]). CJ [1]: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/dma/ti/edma.c#n2173 > >> --- >> 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; >