Skip to content

Commit 651b386

Browse files
npigginelmarco
authored andcommitted
chardev: Fix record/replay error path NULL deref in device creation
qemu_chardev_set_replay() was being called in chardev creation to set up replay parameters even if the chardev is NULL. A segfault can be reproduced by specifying '-serial chardev:bad' with an rr=record mode. Fix this with a NULL pointer check. Reported-by: Peter Maydell <[email protected]> Resolves: Coverity CID 1559470 Fixes: 4c193bb ("chardev: set record/replay on the base device of a muxed device") Signed-off-by: Nicholas Piggin <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Reviewed-by: Peter Maydell <[email protected]> Message-ID: <[email protected]>
1 parent eb22a06 commit 651b386

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

chardev/char.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ static Chardev *__qemu_chr_new(const char *label, const char *filename,
726726

727727
if (strstart(filename, "chardev:", &p)) {
728728
chr = qemu_chr_find(p);
729-
if (replay) {
729+
if (replay && chr) {
730730
qemu_chardev_set_replay(chr, &err);
731731
if (err) {
732732
error_report_err(err);

0 commit comments

Comments
 (0)