diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2010-06-24 00:13:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-27 01:10:04 -0400 |
commit | cc413d9097dfc6237f37dcaf52346db1061a6119 (patch) | |
tree | cc85bed1040342b75785fc85fcb013ae0d0e0595 /drivers/net | |
parent | 1b4843c5e8cbab86830da8a53b8288882060c059 (diff) |
vxge: fix memory leak in vxge_alloc_msix() error path
When pci_enable_msix() returned ret<0, entries and vxge_entries were leaked.
While at it, use the centralized exit idiom in the function.
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Acked-by: Ram Vepa <ram.vepa@exar.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | 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 b504bd561362..d14e207de1df 100644 --- a/drivers/net/vxge/vxge-main.c +++ b/drivers/net/vxge/vxge-main.c | |||
@@ -2262,7 +2262,8 @@ start: | |||
2262 | vxge_debug_init(VXGE_ERR, | 2262 | vxge_debug_init(VXGE_ERR, |
2263 | "%s: memory allocation failed", | 2263 | "%s: memory allocation failed", |
2264 | VXGE_DRIVER_NAME); | 2264 | VXGE_DRIVER_NAME); |
2265 | return -ENOMEM; | 2265 | ret = -ENOMEM; |
2266 | goto alloc_entries_failed; | ||
2266 | } | 2267 | } |
2267 | 2268 | ||
2268 | vdev->vxge_entries = | 2269 | vdev->vxge_entries = |
@@ -2271,8 +2272,8 @@ start: | |||
2271 | if (!vdev->vxge_entries) { | 2272 | if (!vdev->vxge_entries) { |
2272 | vxge_debug_init(VXGE_ERR, "%s: memory allocation failed", | 2273 | vxge_debug_init(VXGE_ERR, "%s: memory allocation failed", |
2273 | VXGE_DRIVER_NAME); | 2274 | VXGE_DRIVER_NAME); |
2274 | kfree(vdev->entries); | 2275 | ret = -ENOMEM; |
2275 | return -ENOMEM; | 2276 | goto alloc_vxge_entries_failed; |
2276 | } | 2277 | } |
2277 | 2278 | ||
2278 | for (i = 0, j = 0; i < vdev->no_of_vpath; i++) { | 2279 | for (i = 0, j = 0; i < vdev->no_of_vpath; i++) { |
@@ -2303,22 +2304,32 @@ start: | |||
2303 | vxge_debug_init(VXGE_ERR, | 2304 | vxge_debug_init(VXGE_ERR, |
2304 | "%s: MSI-X enable failed for %d vectors, ret: %d", | 2305 | "%s: MSI-X enable failed for %d vectors, ret: %d", |
2305 | VXGE_DRIVER_NAME, vdev->intr_cnt, ret); | 2306 | VXGE_DRIVER_NAME, vdev->intr_cnt, ret); |
2307 | if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3)) { | ||
2308 | ret = -ENODEV; | ||
2309 | goto enable_msix_failed; | ||
2310 | } | ||
2311 | |||
2306 | kfree(vdev->entries); | 2312 | kfree(vdev->entries); |
2307 | kfree(vdev->vxge_entries); | 2313 | kfree(vdev->vxge_entries); |
2308 | vdev->entries = NULL; | 2314 | vdev->entries = NULL; |
2309 | vdev->vxge_entries = NULL; | 2315 | vdev->vxge_entries = NULL; |
2310 | |||
2311 | if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3)) | ||
2312 | return -ENODEV; | ||
2313 | /* Try with less no of vector by reducing no of vpaths count */ | 2316 | /* Try with less no of vector by reducing no of vpaths count */ |
2314 | temp = (ret - 1)/2; | 2317 | temp = (ret - 1)/2; |
2315 | vxge_close_vpaths(vdev, temp); | 2318 | vxge_close_vpaths(vdev, temp); |
2316 | vdev->no_of_vpath = temp; | 2319 | vdev->no_of_vpath = temp; |
2317 | goto start; | 2320 | goto start; |
2318 | } else if (ret < 0) | 2321 | } else if (ret < 0) { |
2319 | return -ENODEV; | 2322 | ret = -ENODEV; |
2320 | 2323 | goto enable_msix_failed; | |
2324 | } | ||
2321 | return 0; | 2325 | return 0; |
2326 | |||
2327 | enable_msix_failed: | ||
2328 | kfree(vdev->vxge_entries); | ||
2329 | alloc_vxge_entries_failed: | ||
2330 | kfree(vdev->entries); | ||
2331 | alloc_entries_failed: | ||
2332 | return ret; | ||
2322 | } | 2333 | } |
2323 | 2334 | ||
2324 | static int vxge_enable_msix(struct vxgedev *vdev) | 2335 | static int vxge_enable_msix(struct vxgedev *vdev) |