All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@gmail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	dan.carpenter@oracle.com, Vinod Koul <vkoul@kernel.org>,
	Joel Fernandes <joelf@ti.com>, Sekhar Nori <nsekhar@ti.com>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	dmaengine@vger.kernel.org
Subject: Re: [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw()
Date: Sat, 28 May 2022 12:28:50 +0300	[thread overview]
Message-ID: <1f7277fc-8634-94ff-0fe6-6fd087d8e588@gmail.com> (raw)
In-Reply-To: <8c95c485be294e64457606089a2a56e68e2ebd1a.1653153959.git.christophe.jaillet@wanadoo.fr>



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.

Good catch, obviously this has not been hit for almost a decade :o

Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>

> 
> Fixes: 6d10c3950bf4 ("ARM: edma: Get IP configuration from HW (number of channels, tc, etc)")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> 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;

-- 
Péter

  reply	other threads:[~2022-05-28  9:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21 17:26 [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw() Christophe JAILLET
2022-05-28  9:28 ` Péter Ujfalusi [this message]
2022-05-28  9:33 ` Péter Ujfalusi
2022-05-28 10:06   ` Christophe JAILLET

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f7277fc-8634-94ff-0fe6-6fd087d8e588@gmail.com \
    --to=peter.ujfalusi@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=joelf@ti.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.