Skip to content

Commit

Permalink
spapr_drc.c: do not error_report() when drc->dev->id == NULL
Browse files Browse the repository at this point in the history
The error_report() call in drc_unisolate_logical() is not considering
that drc->dev->id can be NULL, and the underlying functions error_report()
calls to do its job (vprintf(), g_strdup_printf() ...) has undefined
behavior when trying to handle "%s" with NULL arguments.

Besides, there is no utility into reporting that an unknown device was
rejected by the guest.

Acked-by: David Gibson <[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: David Gibson <[email protected]>
  • Loading branch information
danielhb authored and dgibson committed Sep 29, 2021
1 parent 44d886a commit 91bd95c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hw/ppc/spapr_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ static uint32_t drc_unisolate_logical(SpaprDrc *drc)
}

drc->unplug_requested = false;
error_report("Device hotunplug rejected by the guest "
"for device %s", drc->dev->id);

if (drc->dev->id) {
error_report("Device hotunplug rejected by the guest "
"for device %s", drc->dev->id);
}

/*
* TODO: send a QAPI DEVICE_UNPLUG_ERROR event when
Expand Down

0 comments on commit 91bd95c

Please sign in to comment.