From 2dc7fdf33d28940255f171b8ea4b692d9d5b7a7d Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 25 Apr 2014 12:01:55 +0200 Subject: [PATCH] usb: mtp: fix error path memory leak Signed-off-by: Gerd Hoffmann Reviewed-by: Peter Wu Reviewed-by: Stefan Hajnoczi --- hw/usb/dev-mtp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 775dc8d0b2..45f9562c60 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -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; }