mirror of https://github.com/xemu-project/xemu.git
usb-mtp: use safe variant when cleaning events list
usb_mtp_inotify_cleanup uses QLIST_FOREACH to pick events from a list and free them which is incorrect. Use QLIST_FOREACH_SAFE instead. Signed-off-by: Bandan Das <bsd@redhat.com> Message-id: 1450861787-16213-2-git-send-email-bsd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
0922c3f606
commit
c22d5dcd7a
|
@ -556,7 +556,7 @@ static int usb_mtp_inotify_init(MTPState *s)
|
||||||
|
|
||||||
static void usb_mtp_inotify_cleanup(MTPState *s)
|
static void usb_mtp_inotify_cleanup(MTPState *s)
|
||||||
{
|
{
|
||||||
MTPMonEntry *e;
|
MTPMonEntry *e, *p;
|
||||||
|
|
||||||
if (!s->inotifyfd) {
|
if (!s->inotifyfd) {
|
||||||
return;
|
return;
|
||||||
|
@ -565,7 +565,7 @@ static void usb_mtp_inotify_cleanup(MTPState *s)
|
||||||
qemu_set_fd_handler(s->inotifyfd, NULL, NULL, s);
|
qemu_set_fd_handler(s->inotifyfd, NULL, NULL, s);
|
||||||
close(s->inotifyfd);
|
close(s->inotifyfd);
|
||||||
|
|
||||||
QTAILQ_FOREACH(e, &s->events, next) {
|
QTAILQ_FOREACH_SAFE(e, &s->events, next, p) {
|
||||||
QTAILQ_REMOVE(&s->events, e, next);
|
QTAILQ_REMOVE(&s->events, e, next);
|
||||||
g_free(e);
|
g_free(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue