Skip to content

Commit 5b5c7bf

Browse files
dgibsonmdroth
authored andcommitted
PPC: Fix crash on spapr_tce_table_finalize()
spapr_tce_table_finalize() can SEGV if the object was not previously realized. In particular this can be triggered by running qemu-system-ppc -device spapr-tce-table,? The basic problem is that we have mismatched initialization versus finalization: spapr_tce_table_finalize() is attempting to undo things that are done in spapr_tce_table_realize(), not an instance_init function. Therefore, replace spapr_tce_table_finalize() with spapr_tce_table_unrealize(). Signed-off-by: David Gibson <[email protected]> Cc: [email protected] Signed-off-by: Alexander Graf <[email protected]> (cherry picked from commit 5f9490d) Signed-off-by: Michael Roth <[email protected]>
1 parent 6df8cd2 commit 5b5c7bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hw/ppc/spapr_iommu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
172172
return tcet;
173173
}
174174

175-
static void spapr_tce_table_finalize(Object *obj)
175+
static void spapr_tce_table_unrealize(DeviceState *dev, Error **errp)
176176
{
177-
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(obj);
177+
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev);
178178

179179
QLIST_REMOVE(tcet, list);
180180

@@ -419,6 +419,7 @@ static void spapr_tce_table_class_init(ObjectClass *klass, void *data)
419419
DeviceClass *dc = DEVICE_CLASS(klass);
420420
dc->init = spapr_tce_table_realize;
421421
dc->reset = spapr_tce_reset;
422+
dc->unrealize = spapr_tce_table_unrealize;
422423

423424
QLIST_INIT(&spapr_tce_tables);
424425

@@ -434,7 +435,6 @@ static TypeInfo spapr_tce_table_info = {
434435
.parent = TYPE_DEVICE,
435436
.instance_size = sizeof(sPAPRTCETable),
436437
.class_init = spapr_tce_table_class_init,
437-
.instance_finalize = spapr_tce_table_finalize,
438438
};
439439

440440
static void register_types(void)

0 commit comments

Comments
 (0)