[PATCH] staging/hv: Fix memory leak of storvsc_dev_add()

From: Andre Bartke
Date: Wed Jun 01 2011 - 12:18:58 EST


stor_device is not freed in storvsc_dev_add()
causing a memory leak in case of an allocation error.

Signed-off-by: Andre Bartke <andre.bartke@xxxxxxxxx>
---
drivers/staging/hv/storvsc.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 06cd327..3d77c82 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -392,10 +392,8 @@ int storvsc_dev_add(struct hv_device *device,

device_info = (struct storvsc_device_info *)additional_info;
stor_device = alloc_stor_device(device);
- if (!stor_device) {
- ret = -1;
- goto cleanup;
- }
+ if (!stor_device)
+ goto err;

/* Save the channel properties to our storvsc channel */

@@ -413,6 +411,12 @@ int storvsc_dev_add(struct hv_device *device,
device_info->path_id = stor_device->path_id;
device_info->target_id = stor_device->target_id;

+ goto cleanup;
+
+err:
+ ret = -1;
+ free_stor_device(stor_device);
+
cleanup:
return ret;
}
--
1.7.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/