提交 2dc7fdf3 编写于 作者: G Gerd Hoffmann

usb: mtp: fix error path memory leak

Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: NPeter Wu <peter@lekensteyn.nl>
Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 9e4eff5b
...@@ -669,6 +669,7 @@ static MTPData *usb_mtp_get_object(MTPState *s, MTPControl *c, ...@@ -669,6 +669,7 @@ static MTPData *usb_mtp_get_object(MTPState *s, MTPControl *c,
d->fd = open(o->path, O_RDONLY); d->fd = open(o->path, O_RDONLY);
if (d->fd == -1) { if (d->fd == -1) {
usb_mtp_data_free(d);
return NULL; return NULL;
} }
d->length = o->stat.st_size; d->length = o->stat.st_size;
...@@ -688,6 +689,7 @@ static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c, ...@@ -688,6 +689,7 @@ static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c,
d->fd = open(o->path, O_RDONLY); d->fd = open(o->path, O_RDONLY);
if (d->fd == -1) { if (d->fd == -1) {
usb_mtp_data_free(d);
return NULL; return NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册