/* Releases the lock on checksum. */
if (close (fd) == -1) {
perrorf (g, "close");
+ /* Allocated in hard_link_to_cached_appliance above, must be
+ * freed along this error path.
+ */
+ free (*kernel);
+ free (*initrd);
+ free (*appliance);
return -1;
}
guestfs___print_timestamped_message (g, "run febootstrap-supermin-helper");
int r = run_supermin_helper (g, supermin_path, tmpcd, len);
- if (r == -1)
+ if (r == -1) {
+ guestfs___remove_tmpdir (tmpcd);
return -1;
+ }
if (g->verbose)
guestfs___print_timestamped_message (g, "finished building supermin appliance");
int fd = open (filename, O_WRONLY|O_CREAT, 0755);
if (fd == -1) {
perrorf (g, "open: %s", filename);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
struct flock fl;
goto again;
perrorf (g, "fcntl: F_SETLKW: %s", filename);
close (fd);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
if (ftruncate (fd, clen) == -1) {
perrorf (g, "ftruncate: %s", filename);
close (fd);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
if (rr == -1) {
perrorf (g, "write: %s", filename);
close (fd);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
if ((size_t) rr != clen) {
error (g, "partial write: %s", filename);
close (fd);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
if (rename (filename, filename2) == -1) {
perrorf (g, "rename: %s %s", filename, filename2);
close (fd);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
if (rename (filename, filename2) == -1) {
perrorf (g, "rename: %s %s", filename, filename2);
close (fd);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
if (rename (filename, filename2) == -1) {
perrorf (g, "rename: %s %s", filename, filename2);
close (fd);
+ guestfs___remove_tmpdir (tmpcd);
return -1;
}
- rmdir (tmpcd);
+ guestfs___remove_tmpdir (tmpcd);
/* Now finish off by linking to the cached appliance and returning it. */
if (hard_link_to_cached_appliance (g, cachedir,
/* Releases the lock on checksum. */
if (close (fd) == -1) {
perrorf (g, "close");
+ /* Allocated in hard_link_to_cached_appliance above, must be
+ * freed along this error path.
+ */
+ free (*kernel);
+ free (*initrd);
+ free (*appliance);
return -1;
}