page-xfer: add proper initialization and deletion of xfer->parent

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Tikhomirov Pavel 2014-02-06 11:22:00 +04:00 committed by Pavel Emelyanov
parent 2824c968e7
commit e18ae2a8f5

View file

@ -557,6 +557,11 @@ static int write_pagehole_loc(struct page_xfer *xfer, struct iovec *iov)
static void close_page_xfer(struct page_xfer *xfer)
{
if (xfer->parent != NULL) {
xfer->parent->close(xfer->parent);
xfree(xfer->parent);
xfer->parent = NULL;
}
close(xfer->fd_pg);
close(xfer->fd);
}
@ -640,6 +645,8 @@ static int open_page_local_xfer(struct page_xfer *xfer, int fd_type, long id)
int ret;
int pfd;
xfer->parent = NULL;
pfd = openat(get_service_fd(IMG_FD_OFF), CR_PARENT_LINK, O_RDONLY);
if (pfd < 0 && errno == ENOENT)
goto out;