9pfs: Fix CLI parsing crash on error
Calling error_report() in a function that takes an Error ** argument is suspicious. 9p-handle.c's handle_parse_opts() does that, and then fails without setting an error. Wrong. Its caller crashes when it tries to report the error: $ qemu-system-x86_64 -nodefaults -fsdev id=foo,fsdriver=handle qemu-system-x86_64: -fsdev id=foo,fsdriver=handle: warning: handle backend is deprecated qemu-system-x86_64: -fsdev id=foo,fsdriver=handle: fsdev: No path specified Segmentation fault (core dumped) Screwed up when commit91cda4e8f3
(v2.12.0) converted the function to Error. Fix by calling error_setg() instead of error_report(). Fixes:91cda4e8f3
Cc: Greg Kurz <groug@kaod.org> Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Greg Kurz <groug@kaod.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20181017082702.5581-9-armbru@redhat.com>
This commit is contained in:
parent
b1b769b0f3
commit
1245402e3c
|
@ -19,6 +19,7 @@
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
#include "qapi/error.h"
|
||||||
#include "qemu/xattr.h"
|
#include "qemu/xattr.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
|
@ -655,12 +656,13 @@ static int handle_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
|
||||||
warn_report("handle backend is deprecated");
|
warn_report("handle backend is deprecated");
|
||||||
|
|
||||||
if (sec_model) {
|
if (sec_model) {
|
||||||
error_report("Invalid argument security_model specified with handle fsdriver");
|
error_setg(errp,
|
||||||
|
"Invalid argument security_model specified with handle fsdriver");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
error_report("fsdev: No path specified");
|
error_setg(errp, "fsdev: No path specified");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fse->path = g_strdup(path);
|
fse->path = g_strdup(path);
|
||||||
|
|
Loading…
Reference in New Issue