lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fc381683-00b8-ffae-b225-35317e538ac1@huawei.com>
Date:   Wed, 28 Jun 2023 17:48:42 +0800
From:   shaozhengchao <shaozhengchao@...wei.com>
To:     Ido Schimmel <idosch@...dia.com>
CC:     <netdev@...r.kernel.org>, <davem@...emloft.net>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <petrm@...dia.com>, <jiri@...nulli.us>, <vadimp@...dia.com>,
        <yuehaibing@...wei.com>
Subject: Re: [PATCH net] mlxsw: minimal: fix potential memory leak in
 mlxsw_m_linecards_init



On 2023/6/28 17:03, Ido Schimmel wrote:
> On Wed, Jun 28, 2023 at 08:54:10AM +0800, Zhengchao Shao wrote:
>> when allocating mlxsw_m->line_cards[] failed in mlxsw_m_linecards_init,
> 
Hi Ido:
> s/when/When/
> s/allocating/the allocation of/
> s/failed/fails/
> 
>> the memory pointed by mlxsw_m->line_cards is not released, which will
>> cause memory leak. Memory release processing is added to the incorrect
>> path.
> 
> Last sentence should be reworded to imperative mood.
> 
> Personally, I would reword the commit message to something like:
> 
> "
> The line cards array is not freed in the error path of
> mlxsw_m_linecards_init(), which can lead to a memory leak. Fix by
> freeing the array in the error path, thereby making the error path
> identical to mlxsw_m_linecards_fini().
> "
> 
	Thank you for your reply. I will send v2.

Zhengchao Shao
> Thanks
> 
>>
>> Fixes: 01328e23a476 ("mlxsw: minimal: Extend module to port mapping with slot index")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@...wei.com>
>> ---
>>   drivers/net/ethernet/mellanox/mlxsw/minimal.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
>> index 6b56eadd736e..6b98c3287b49 100644
>> --- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
>> +++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
>> @@ -417,6 +417,7 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m)
>>   err_kmalloc_array:
>>   	for (i--; i >= 0; i--)
>>   		kfree(mlxsw_m->line_cards[i]);
>> +	kfree(mlxsw_m->line_cards);
>>   err_kcalloc:
>>   	kfree(mlxsw_m->ports);
>>   	return err;
>> -- 
>> 2.34.1
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ