Skip to content

Commit

Permalink
qemu-char: avoid leak in qemu_chr_open_pp_fd
Browse files Browse the repository at this point in the history
drv leaks if qemu_chr_alloc returns an error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jan 26, 2016
1 parent 8485140 commit 27ef9cb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions qemu-char.c
Expand Up @@ -1740,18 +1740,19 @@ static CharDriverState *qemu_chr_open_pp_fd(int fd,
return NULL;
}

drv = g_new0(ParallelCharDriver, 1);
drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;

chr = qemu_chr_alloc(backend, errp);
if (!chr) {
return NULL;
}

drv = g_new0(ParallelCharDriver, 1);
chr->opaque = drv;
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
chr->opaque = drv;

drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;

return chr;
}
Expand Down

0 comments on commit 27ef9cb

Please sign in to comment.