Fix segmentation fault when qemu_signal_init fails
When qemu_signal_init() fails in qemu_init_main_loop(), we return
without setting an error. Its callers crash then when they try to
report the error with error_report_err().
To avoid such segmentation fault, add a new Error parameter to make
the call trace to propagate the err to the final caller.
Fixes: 2f78e491d7
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fei Li <fli@suse.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190113140849.38339-2-lifei1214@126.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
9f33051abc
commit
78524330fd
@ -71,7 +71,7 @@ static void sigfd_handler(void *opaque)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemu_signal_init(void)
|
static int qemu_signal_init(Error **errp)
|
||||||
{
|
{
|
||||||
int sigfd;
|
int sigfd;
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
@ -96,7 +96,7 @@ static int qemu_signal_init(void)
|
|||||||
sigdelset(&set, SIG_IPI);
|
sigdelset(&set, SIG_IPI);
|
||||||
sigfd = qemu_signalfd(&set);
|
sigfd = qemu_signalfd(&set);
|
||||||
if (sigfd == -1) {
|
if (sigfd == -1) {
|
||||||
fprintf(stderr, "failed to create signalfd\n");
|
error_setg_errno(errp, errno, "failed to create signalfd");
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ static int qemu_signal_init(void)
|
|||||||
|
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
|
|
||||||
static int qemu_signal_init(void)
|
static int qemu_signal_init(Error **errp)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ int qemu_init_main_loop(Error **errp)
|
|||||||
|
|
||||||
init_clocks(qemu_timer_notify_cb);
|
init_clocks(qemu_timer_notify_cb);
|
||||||
|
|
||||||
ret = qemu_signal_init();
|
ret = qemu_signal_init(errp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user