On 27 June 2016 at 17:16, Alistair Francis <alistair.fran...@xilinx.com> wrote: > On Mon, Jun 27, 2016 at 7:31 AM, Peter Maydell <peter.mayd...@linaro.org> > wrote: >> On 24 June 2016 at 16:42, Alistair Francis <alistair.fran...@xilinx.com> >> wrote: >>> +/** >>> + * This function should be called to cleanup the registers that were >>> initialized >>> + * when calling register_init_block32() >>> + * >>> + * @r_array: An structure containing all of the registers. The caller is in >>> + * charge of cleaning up the memory region (r_array->mem). >> >> What cleanup does the memory region require? > > The device init function that calls the register init function will > also call memory_region_add_subregion(). Doesn't it need to call > memory_region_del_subregion() afterwards?
Somebody also needs to call object_unparent() if the MemoryRegion is part of a lump of memory that's being g_free()d (see docs/memory.txt). That probably ought to be this code, and we should say that this function should only be called from the owner device's instance_finalize. More generally: I think we should be specific, not vague, about exactly what the caller's responsibilities are [what they are expected to have done before calling this function; when they are permitted to call it]; otherwise the callers will likely get it wrong. thanks -- PMM