* [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path
@ 2010-06-24 14:13 Michal Schmidt
2010-06-25 7:21 ` [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path {nodisc} Ramkrishna Vepa
0 siblings, 1 reply; 3+ messages in thread
From: Michal Schmidt @ 2010-06-24 14:13 UTC (permalink / raw)
To: Ramkrishna Vepa; +Cc: netdev
When pci_enable_msix() returned ret<0, entries and vxge_entries were leaked.
While at it, use the centralized exit idiom in the function.
Not tested. It compiles OK.
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
drivers/net/vxge/vxge-main.c | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index 45c5dc2..8b9e73b 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -2262,7 +2262,8 @@ start:
vxge_debug_init(VXGE_ERR,
"%s: memory allocation failed",
VXGE_DRIVER_NAME);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto alloc_entries_failed;
}
vdev->vxge_entries =
@@ -2271,8 +2272,8 @@ start:
if (!vdev->vxge_entries) {
vxge_debug_init(VXGE_ERR, "%s: memory allocation failed",
VXGE_DRIVER_NAME);
- kfree(vdev->entries);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto alloc_vxge_entries_failed;
}
for (i = 0, j = 0; i < vdev->no_of_vpath; i++) {
@@ -2303,22 +2304,32 @@ start:
vxge_debug_init(VXGE_ERR,
"%s: MSI-X enable failed for %d vectors, ret: %d",
VXGE_DRIVER_NAME, vdev->intr_cnt, ret);
+ if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3)) {
+ ret = -ENODEV;
+ goto enable_msix_failed;
+ }
+
kfree(vdev->entries);
kfree(vdev->vxge_entries);
vdev->entries = NULL;
vdev->vxge_entries = NULL;
-
- if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3))
- return -ENODEV;
/* Try with less no of vector by reducing no of vpaths count */
temp = (ret - 1)/2;
vxge_close_vpaths(vdev, temp);
vdev->no_of_vpath = temp;
goto start;
- } else if (ret < 0)
- return -ENODEV;
-
+ } else if (ret < 0) {
+ ret = -ENODEV;
+ goto enable_msix_failed;
+ }
return 0;
+
+enable_msix_failed:
+ kfree(vdev->vxge_entries);
+alloc_vxge_entries_failed:
+ kfree(vdev->entries);
+alloc_entries_failed:
+ return ret;
}
static int vxge_enable_msix(struct vxgedev *vdev)
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path {nodisc}
2010-06-24 14:13 [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path Michal Schmidt
@ 2010-06-25 7:21 ` Ramkrishna Vepa
2010-06-27 5:12 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Ramkrishna Vepa @ 2010-06-25 7:21 UTC (permalink / raw)
To: Michal Schmidt; +Cc: netdev@vger.kernel.org
> When pci_enable_msix() returned ret<0, entries and vxge_entries were
> leaked.
> While at it, use the centralized exit idiom in the function.
>
> Not tested. It compiles OK.
>
> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Reviewed and tested the patch. Thanks!
Acked-by: Ram Vepa <ram.vepa@exar.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path {nodisc}
2010-06-25 7:21 ` [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path {nodisc} Ramkrishna Vepa
@ 2010-06-27 5:12 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2010-06-27 5:12 UTC (permalink / raw)
To: Ramkrishna.Vepa; +Cc: mschmidt, netdev
From: Ramkrishna Vepa <Ramkrishna.Vepa@exar.com>
Date: Fri, 25 Jun 2010 00:21:48 -0700
>> When pci_enable_msix() returned ret<0, entries and vxge_entries were
>> leaked.
>> While at it, use the centralized exit idiom in the function.
>>
>> Not tested. It compiles OK.
>>
>> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
>
> Reviewed and tested the patch. Thanks!
>
> Acked-by: Ram Vepa <ram.vepa@exar.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-27 5:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-24 14:13 [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path Michal Schmidt
2010-06-25 7:21 ` [PATCH] vxge: fix memory leak in vxge_alloc_msix() error path {nodisc} Ramkrishna Vepa
2010-06-27 5:12 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).