public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ziyang Xuan (William)" <william.xuanziyang@huawei.com>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	<sunil.kovvuri@gmail.com>, <sgoutham@marvell.com>
Cc: <gakula@marvell.com>, <sbhatta@marvell.com>, <hkelam@marvell.com>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <netdev@vger.kernel.org>,
	<naveenm@marvell.com>, <rsaladi2@marvell.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe()
Date: Sat, 26 Nov 2022 09:04:56 +0800	[thread overview]
Message-ID: <f4bb4aa5-08cc-4a4d-76cf-46bda5c6de59@huawei.com> (raw)
In-Reply-To: <Y4DHHUUbGl5wWGQ+@boxer>

> On Thu, Nov 24, 2022 at 09:56:43AM +0800, Ziyang Xuan wrote:
>> In otx2_probe(), there are several possible memory leak bugs
>> in exception paths as follows:
>> 1. Do not release pf->otx2_wq when excute otx2_init_tc() failed.
>> 2. Do not shutdown tc when excute otx2_register_dl() failed.
>> 3. Do not unregister devlink when initialize SR-IOV failed.
>>
>> Fixes: 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")
>> Fixes: 2da489432747 ("octeontx2-pf: devlink params support to set mcam entry count")
>> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
>> ---
>>  drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
>> index 303930499a4c..8d7f2c3b0cfd 100644
>> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
>> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
>> @@ -2900,7 +2900,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>>  
>>  	err = otx2_register_dl(pf);
>>  	if (err)
>> -		goto err_mcam_flow_del;
>> +		goto err_register_dl;
>>  
>>  	/* Initialize SR-IOV resources */
>>  	err = otx2_sriov_vfcfg_init(pf);
>> @@ -2919,8 +2919,11 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>>  	return 0;
> 
> If otx2_dcbnl_set_ops() fails at the end then shouldn't we also call
> otx2_sriov_vfcfg_cleanup() ?

I think it does not need. This is the probe process. PF and VF are all not ready to work,
so pf->vf_configs[i].link_event_work does not scheduled. And pf->vf_configs memory resource will
be freed by devm subsystem if probe failed. There are not memory leak and other problems.

@Sunil Goutham, Please help to confirm.

Thanks.

> 
>>  
>>  err_pf_sriov_init:
>> +	otx2_unregister_dl(pf);
>> +err_register_dl:
>>  	otx2_shutdown_tc(pf);
>>  err_mcam_flow_del:
>> +	destroy_workqueue(pf->otx2_wq);
>>  	otx2_mcam_flow_del(pf);
>>  err_unreg_netdev:
>>  	unregister_netdev(netdev);
>> -- 
>> 2.25.1
>>
> .
> 

  reply	other threads:[~2022-11-26  1:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24  1:56 [PATCH net 0/2] octeontx2: Fix several bugs in exception paths Ziyang Xuan
2022-11-24  1:56 ` [PATCH net 1/2] octeontx2-pf: Fix possible memory leak in otx2_probe() Ziyang Xuan
2022-11-25 13:46   ` Maciej Fijalkowski
2022-11-26  1:04     ` Ziyang Xuan (William) [this message]
2022-12-02  1:44       ` Ziyang Xuan (William)
2022-12-02  6:38         ` [EXT] " Geethasowjanya Akula
2022-12-02  8:34           ` Ziyang Xuan (William)
2022-12-02  9:50             ` Geethasowjanya Akula
2022-11-24  1:56 ` [PATCH net 2/2] octeontx2-vf: Fix possible memory leak in otx2vf_probe() Ziyang Xuan

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=f4bb4aa5-08cc-4a4d-76cf-46bda5c6de59@huawei.com \
    --to=william.xuanziyang@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=naveenm@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rsaladi2@marvell.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=sunil.kovvuri@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox