Free allocated memory on failure (v2)

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
Christian Brauner 2015-09-28 13:33:33 +02:00 committed by Stéphane Graber
parent 2b54359b24
commit 196a808645

View File

@ -2461,12 +2461,15 @@ static int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char
// and needs to be on the same filesystem as upperdir,
// so it's OK for it to be empty.
work = malloc(lastslashidx + 7);
if (!work)
if (!work) {
free(delta);
return -1;
}
strncpy(work, new->dest, lastslashidx+1);
strcpy(work+lastslashidx, "olwork");
if (mkdir(work, 0755) < 0) {
SYSERROR("error: mkdir %s", work);
free(delta);
free(work);
return -1;
}