* [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw()
@ 2022-05-21 17:26 Christophe JAILLET
2022-05-28 9:28 ` Péter Ujfalusi
2022-05-28 9:33 ` Péter Ujfalusi
0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-05-21 17:26 UTC (permalink / raw)
To: dan.carpenter, Peter Ujfalusi, Vinod Koul, Joel Fernandes, Sekhar Nori
Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
Peter Ujfalusi, dmaengine
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 <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;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw()
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
2022-05-28 9:33 ` Péter Ujfalusi
1 sibling, 0 replies; 4+ messages in thread
From: Péter Ujfalusi @ 2022-05-28 9:28 UTC (permalink / raw)
To: Christophe JAILLET, dan.carpenter, Vinod Koul, Joel Fernandes,
Sekhar Nori
Cc: linux-kernel, kernel-janitors, Peter Ujfalusi, dmaengine
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw()
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
@ 2022-05-28 9:33 ` Péter Ujfalusi
2022-05-28 10:06 ` Christophe JAILLET
1 sibling, 1 reply; 4+ messages in thread
From: Péter Ujfalusi @ 2022-05-28 9:33 UTC (permalink / raw)
To: Christophe JAILLET, dan.carpenter, Vinod Koul, Joel Fernandes,
Sekhar Nori
Cc: linux-kernel, kernel-janitors, Peter Ujfalusi, dmaengine
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 <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.
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.
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dmaengine: ti: Fix a potential under memory allocation issue in edma_setup_from_hw()
2022-05-28 9:33 ` Péter Ujfalusi
@ 2022-05-28 10:06 ` Christophe JAILLET
0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-05-28 10:06 UTC (permalink / raw)
To: Péter Ujfalusi, dan.carpenter, Vinod Koul, Joel Fernandes,
Sekhar Nori
Cc: linux-kernel, kernel-janitors, Peter Ujfalusi, dmaengine
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 <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.
>
> 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;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-28 10:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-05-28 9:33 ` Péter Ujfalusi
2022-05-28 10:06 ` Christophe JAILLET
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.