Skip to contentSkip to conversation

staging: altera-stapl: fix memory leaks

PATCH New Alexander Beregalov 1 participant 1 message Mar 13, 2011 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: altera-stapl: fix memory leaks

Free resources before exit.

---
 drivers/staging/altera-stapl/altera.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/staging/altera-stapl/altera.c +7 -2
index 05aad35..fcc7650 100644
@@ -2435,11 +2435,16 @@ int altera_init(struct altera_config *config, const struct firmware *fw)
 	if (!key)
 		return -ENOMEM;
 	value = kzalloc(257 * sizeof(char), GFP_KERNEL);
-	if (!value)
+	if (!value) {
+		kfree(key);
 		return -ENOMEM;
+	}
 	astate = kzalloc(sizeof(struct altera_state), GFP_KERNEL);
-	if (!astate)
+	if (!astate) {
+		kfree(value);
+		kfree(key);
 		return -ENOMEM;
+	}
 
 	astate->config = config;
 	if (!astate->config->jtag_io) {
Signature · 1 line
1.7.4.1