Skip to contentSkip to conversation

md: memory leak on error path in dm_exception_store_create()

PATCH New Dan Carpenter 1 participant 1 message Jul 19, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md: memory leak on error path in dm_exception_store_create()

tmp_store should be freed if the persistent flag is invalid.

Compile tested only. Sorry. Found by smatch
(http://repo.or.cz/w/smatch.git).

regards,
dan carpenter

drivers/md/dm-exception-store.c +4 -3
@@ -217,13 +217,14 @@
 		type = get_type("N");
 	else {
 		ti->error = "Persistent flag is not P or N";
-		return -EINVAL;
+		r = -EINVAL;
+		goto out_free;
 	}
 
 	if (!type) {
 		ti->error = "Exception store type not recognised";
 		r = -EINVAL;
-		goto bad_type;
+		goto out_free;
 	}
 
 	tmp_store->type = type;
@@ -254,7 +255,7 @@
 	dm_put_device(ti, tmp_store->cow);
 bad_cow:
 	put_type(type);
-bad_type:
+out_free:
 	kfree(tmp_store);
 	return r;
 }