From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001
From: Tanmay Bhushan <[email protected]>
Date: Tue, 27 Dec 2022 22:02:16 +0100
Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails
ifcvf_mgmt_dev leaks memory if it is not freed before
returning. Call is made to correct return statement
so memory does not leak. ifcvf_init_hw does not take
care of this so it is needed to do it here.
Signed-off-by: Tanmay Bhushan <[email protected]>
---
drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c
b/drivers/vdpa/ifcvf/ifcvf_main.c
index f9c0044c6442..44b29289aa19 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const
struct pci_device_id *id)
ret = ifcvf_init_hw(vf, pdev);
if (ret) {
IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
- return ret;
+ goto err;
}
for (i = 0; i < vf->nr_vring; i++)
--
2.34.1
On Wed, Dec 28, 2022 at 5:15 AM Tanmay Bhushan <[email protected]> wrote:
>
> From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001
> From: Tanmay Bhushan <[email protected]>
> Date: Tue, 27 Dec 2022 22:02:16 +0100
> Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails
>
> ifcvf_mgmt_dev leaks memory if it is not freed before
> returning. Call is made to correct return statement
> so memory does not leak. ifcvf_init_hw does not take
> care of this so it is needed to do it here.
>
> Signed-off-by: Tanmay Bhushan <[email protected]>
Acked-by: Jason Wang <[email protected]>
Thanks
> ---
> drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c
> b/drivers/vdpa/ifcvf/ifcvf_main.c
> index f9c0044c6442..44b29289aa19 100644
> --- a/drivers/vdpa/ifcvf/ifcvf_main.c
> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c
> @@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const
> struct pci_device_id *id)
> ret = ifcvf_init_hw(vf, pdev);
> if (ret) {
> IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
> - return ret;
> + goto err;
> }
>
> for (i = 0; i < vf->nr_vring; i++)
> --
> 2.34.1
>
>
On 12/28/2022 2:58 PM, Jason Wang wrote:
> On Wed, Dec 28, 2022 at 5:15 AM Tanmay Bhushan <[email protected]> wrote:
>> From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001
>> From: Tanmay Bhushan <[email protected]>
>> Date: Tue, 27 Dec 2022 22:02:16 +0100
>> Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails
>>
>> ifcvf_mgmt_dev leaks memory if it is not freed before
>> returning. Call is made to correct return statement
>> so memory does not leak. ifcvf_init_hw does not take
>> care of this so it is needed to do it here.
>>
>> Signed-off-by: Tanmay Bhushan <[email protected]>
> Acked-by: Jason Wang <[email protected]>
>
> Thanks
Acked-by: Zhu Lingshan <[email protected]>
Thanks
>
>> ---
>> drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c
>> b/drivers/vdpa/ifcvf/ifcvf_main.c
>> index f9c0044c6442..44b29289aa19 100644
>> --- a/drivers/vdpa/ifcvf/ifcvf_main.c
>> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c
>> @@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const
>> struct pci_device_id *id)
>> ret = ifcvf_init_hw(vf, pdev);
>> if (ret) {
>> IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
>> - return ret;
>> + goto err;
>> }
>>
>> for (i = 0; i < vf->nr_vring; i++)
>> --
>> 2.34.1
>>
>>
On Tue, Dec 27, 2022 at 10:15:25PM +0100, Tanmay Bhushan wrote:
> >From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001
> From: Tanmay Bhushan <[email protected]>
> Date: Tue, 27 Dec 2022 22:02:16 +0100
> Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails
>
> ifcvf_mgmt_dev leaks memory if it is not freed before
> returning. Call is made to correct return statement
> so memory does not leak. ifcvf_init_hw does not take
> care of this so it is needed to do it here.
>
> Signed-off-by: Tanmay Bhushan <[email protected]>
> ---
> drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c
> b/drivers/vdpa/ifcvf/ifcvf_main.c
> index f9c0044c6442..44b29289aa19 100644
> --- a/drivers/vdpa/ifcvf/ifcvf_main.c
> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c
> @@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const
> struct pci_device_id *id)
BTW your patch was mangled but I fixed it.
> ret = ifcvf_init_hw(vf, pdev);
> if (ret) {
> IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
> - return ret;
> + goto err;
> }
>
> for (i = 0; i < vf->nr_vring; i++)
> --
> 2.34.1
>