net/sfc: fix the argument to sizeof for unit cache

Message ID tencent_1990BE73477645EE63B078424EDD235E7409@qq.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: fix the argument to sizeof for unit cache |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Weiguo Li Dec. 21, 2021, 6:41 a.m. UTC
  The size of unit cache should be sizeof(**cache) instead of
sizeof(*cache). Memory reallocation is inadequate by sizeof(*cache)
for the platform whose size of pointer is 32-bits. Found by coccinelle
(see https://coccinelle.gitlabpages.inria.fr/website) script.

Fixes: 63abf8d29225 ("net/sfc: support SW stats groups")
Cc: stable@dpdk.org

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
 drivers/net/sfc/sfc_sw_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit Feb. 18, 2022, 2:38 p.m. UTC | #1
On 12/21/2021 6:41 AM, Weiguo Li wrote:
> The size of unit cache should be sizeof(**cache) instead of
> sizeof(*cache). Memory reallocation is inadequate by sizeof(*cache)
> for the platform whose size of pointer is 32-bits. Found by coccinelle
> (see https://coccinelle.gitlabpages.inria.fr/website) script.
> 
> Fixes: 63abf8d29225 ("net/sfc: support SW stats groups")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Weiguo Li <liwg06@foxmail.com>
> ---
>   drivers/net/sfc/sfc_sw_stats.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/sfc/sfc_sw_stats.c b/drivers/net/sfc/sfc_sw_stats.c
> index 70259660c0..81f5aa3cc4 100644
> --- a/drivers/net/sfc/sfc_sw_stats.c
> +++ b/drivers/net/sfc/sfc_sw_stats.c
> @@ -777,7 +777,7 @@ sfc_sw_xstats_configure(struct sfc_adapter *sa)
>   
>   	memset(*reset_vals, 0, nb_supported * sizeof(**reset_vals));
>   
> -	*cache = rte_realloc(*cache, cache_count * sizeof(*cache), 0);
> +	*cache = rte_realloc(*cache, cache_count * sizeof(**cache), 0);
>   	if (*cache == NULL) {
>   		rc = ENOMEM;
>   		goto fail_cache;


Hi Andrew, Ivan,

This patch seems missed, and it looks a valid fix to me.

Do you have any comment on patch?
  
Andrew Rybchenko Feb. 18, 2022, 2:43 p.m. UTC | #2
On 2/18/22 17:38, Ferruh Yigit wrote:
> On 12/21/2021 6:41 AM, Weiguo Li wrote:
>> The size of unit cache should be sizeof(**cache) instead of
>> sizeof(*cache). Memory reallocation is inadequate by sizeof(*cache)
>> for the platform whose size of pointer is 32-bits. Found by coccinelle
>> (see https://coccinelle.gitlabpages.inria.fr/website) script.
>>
>> Fixes: 63abf8d29225 ("net/sfc: support SW stats groups")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Weiguo Li <liwg06@foxmail.com>
>> ---
>>   drivers/net/sfc/sfc_sw_stats.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/sfc/sfc_sw_stats.c 
>> b/drivers/net/sfc/sfc_sw_stats.c
>> index 70259660c0..81f5aa3cc4 100644
>> --- a/drivers/net/sfc/sfc_sw_stats.c
>> +++ b/drivers/net/sfc/sfc_sw_stats.c
>> @@ -777,7 +777,7 @@ sfc_sw_xstats_configure(struct sfc_adapter *sa)
>>       memset(*reset_vals, 0, nb_supported * sizeof(**reset_vals));
>> -    *cache = rte_realloc(*cache, cache_count * sizeof(*cache), 0);
>> +    *cache = rte_realloc(*cache, cache_count * sizeof(**cache), 0);
>>       if (*cache == NULL) {
>>           rc = ENOMEM;
>>           goto fail_cache;
> 
> 
> Hi Andrew, Ivan,
> 
> This patch seems missed, and it looks a valid fix to me.
> 
> Do you have any comment on patch?

Hi,

sorry, lost from my view as well.

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Thanks,
Andrew.
  
Ferruh Yigit Feb. 18, 2022, 3:50 p.m. UTC | #3
On 2/18/2022 2:43 PM, Andrew Rybchenko wrote:
> On 2/18/22 17:38, Ferruh Yigit wrote:
>> On 12/21/2021 6:41 AM, Weiguo Li wrote:
>>> The size of unit cache should be sizeof(**cache) instead of
>>> sizeof(*cache). Memory reallocation is inadequate by sizeof(*cache)
>>> for the platform whose size of pointer is 32-bits. Found by coccinelle
>>> (see https://coccinelle.gitlabpages.inria.fr/website) script.
>>>
>>> Fixes: 63abf8d29225 ("net/sfc: support SW stats groups")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Weiguo Li <liwg06@foxmail.com>
> 
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/sfc/sfc_sw_stats.c b/drivers/net/sfc/sfc_sw_stats.c
index 70259660c0..81f5aa3cc4 100644
--- a/drivers/net/sfc/sfc_sw_stats.c
+++ b/drivers/net/sfc/sfc_sw_stats.c
@@ -777,7 +777,7 @@  sfc_sw_xstats_configure(struct sfc_adapter *sa)
 
 	memset(*reset_vals, 0, nb_supported * sizeof(**reset_vals));
 
-	*cache = rte_realloc(*cache, cache_count * sizeof(*cache), 0);
+	*cache = rte_realloc(*cache, cache_count * sizeof(**cache), 0);
 	if (*cache == NULL) {
 		rc = ENOMEM;
 		goto fail_cache;