Skip to content

Commit 5f9490d

Browse files
dgibsonagraf
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]>
1 parent 77bad15 commit 5f9490d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hw/ppc/spapr_iommu.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
173173
return tcet;
174174
}
175175

176-
static void spapr_tce_table_finalize(Object *obj)
176+
static void spapr_tce_table_unrealize(DeviceState *dev, Error **errp)
177177
{
178-
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(obj);
178+
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev);
179179

180180
QLIST_REMOVE(tcet, list);
181181

@@ -420,6 +420,7 @@ static void spapr_tce_table_class_init(ObjectClass *klass, void *data)
420420
DeviceClass *dc = DEVICE_CLASS(klass);
421421
dc->init = spapr_tce_table_realize;
422422
dc->reset = spapr_tce_reset;
423+
dc->unrealize = spapr_tce_table_unrealize;
423424

424425
QLIST_INIT(&spapr_tce_tables);
425426

@@ -435,7 +436,6 @@ static TypeInfo spapr_tce_table_info = {
435436
.parent = TYPE_DEVICE,
436437
.instance_size = sizeof(sPAPRTCETable),
437438
.class_init = spapr_tce_table_class_init,
438-
.instance_finalize = spapr_tce_table_finalize,
439439
};
440440

441441
static void register_types(void)

0 commit comments

Comments
 (0)