hmp: Fix drive_add ... format=help crash
PATCH 1/1 hmp: Fix drive_add ... format=help crash
drive_new() returns null without setting an error when it provided help. add_init_drive() assumes null means failure, and crashes trying to report a null error.
--- device-hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
device-hotplug.c +1 -1
@@ -48,7 +48,7 @@ static DriveInfo *add_init_drive(const char *optstr) mc =MACHINE_GET_CLASS (current_machine); dinfo =drive_new (opts, mc->block_default_type, &err); -if (!dinfo) { +if (err) {error_report_err (err);qemu_opts_del (opts);return NULL ;
Signature · 1 line
2.17.2
Am 05.04.2019 um 13:45 hat Markus Armbruster geschrieben:
Quoted 7 lines
drive_new()returns null without setting an error when it provided help.add_init_drive()assumes null means failure, and crashes trying to report a null error.Fixes c4f26c9f37ce511e5fe629c21c180dc6eb7c5a25Signed-off-by Markus Armbruster <[email protected]>
We should probably have a test case for this.
Kevin
Quoted 10 lines · * Kevin Wolf ([email protected]) wrote:
Am 05.04.2019 um 13:45 hat Markus Armbruster geschrieben:
Quoted 7 lines
drive_new()returns null without setting an error when it provided help.add_init_drive()assumes null means failure, and crashes trying to report a null error.Fixes c4f26c9f37ce511e5fe629c21c180dc6eb7c5a25Signed-off-by Markus Armbruster <[email protected]>We should probably have a test case for this.
Perhaps just adding:
drive_add 0 format=help
to the hmp_cmds list in tests/test-hmp.c ?
Dave
Quoted 2 lines
Kevin
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Am 05.04.2019 um 18:11 hat Dr. David Alan Gilbert geschrieben:
Quoted 10 lines · * Kevin Wolf ([email protected]) wrote:
Quoted 9 lines
Am 05.04.2019 um 13:45 hat Markus Armbruster geschrieben:
Quoted 7 lines
drive_new()returns null without setting an error when it provided help.add_init_drive()assumes null means failure, and crashes trying to report a null error.Fixes c4f26c9f37ce511e5fe629c21c180dc6eb7c5a25Signed-off-by Markus Armbruster <[email protected]>
Quoted 7 lines
Quoted 1 line
We should probably have a test case for this.
Perhaps just adding:
drive_add0 format=helpto the
hmp_cmdslist intests/test-hmp.c?
This would catch the crash, but not check the output. I think I'd prefer a qemu-iotests case where the output is checked.
Kevin