usb: mtp: fix error path memory leak

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Gerd Hoffmann 2014-04-25 12:01:55 +02:00
parent 9e4eff5b54
commit 2dc7fdf33d
1 changed files with 2 additions and 0 deletions

View File

@ -669,6 +669,7 @@ static MTPData *usb_mtp_get_object(MTPState *s, MTPControl *c,
d->fd = open(o->path, O_RDONLY);
if (d->fd == -1) {
usb_mtp_data_free(d);
return NULL;
}
d->length = o->stat.st_size;
@ -688,6 +689,7 @@ static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c,
d->fd = open(o->path, O_RDONLY);
if (d->fd == -1) {
usb_mtp_data_free(d);
return NULL;
}