On Tue, 6 Jun 2017 16:00:32 +0100 Peter Maydell <peter.mayd...@linaro.org> wrote:
> On 25 May 2017 at 04:51, David Gibson <da...@gibson.dropbear.id.au> wrote: > > From: Laurent Vivier <lviv...@redhat.com> > > > > This allows to manage errors before the memory > > has started to be hotplugged. We already have > > the function for the CPU cores. > > > +static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState > > *dev, > > + Error **errp) > > +{ > > + PCDIMMDevice *dimm = PC_DIMM(dev); > > + PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); > > + MemoryRegion *mr = ddc->get_memory_region(dimm); > > + uint64_t size = memory_region_size(mr); > > + char *mem_dev; > > + > > + if (size % SPAPR_MEMORY_BLOCK_SIZE) { > > + error_setg(errp, "Hotplugged memory size must be a multiple of " > > + "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE); > > + return; > > + } > > + > > + mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, > > NULL); > > + if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { > > + error_setg(errp, "Memory backend has bad page size. " > > + "Use 'memory-backend-file' with correct mem-path."); > > + return; > > + } > > +} > > Coverity points out that this leaks memory -- object_property_get_str() > returns a copy of a string which the caller is supposed to free, but > this code doesn't free it. (CID 1375942.) > Yeah, I've received the Coverity report as well. This is a regression introduced in 2.9 by commit df58713396f8 ("hw/ppc/spapr: Check for valid page size when hot plugging memory") actually. The same commit also introduces a similar leak in kvmppc_is_mem_backend_page_size_ok(). I'm about to send a series to fix both. Cheers. -- Greg > thanks > -- PMM >
pgpojwpU5RKb7.pgp
Description: OpenPGP digital signature