[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v1 4/4] libxl: info: Display build_id of the hypervisor.



On Fri, 2015-10-09 at 14:06 +0100, Ian Campbell wrote:
> On Fri, 2015-10-09 at 13:59 +0100, Andrew Cooper wrote:
> > On 09/10/15 03:56, Konrad Rzeszutek Wilk wrote:
> > > +    rc = xc_version_len(ctx->xch, XENVER_build_id, &u.build_id,
> > > BUILD_ID_LEN);
> > > +    if (rc > 0) {
> > > +        unsigned int i;
> > > +
> > > +        info->build_id = (char *)malloc((rc * 2) + 1);
> > > +
> > > +        for (i = 0; i < rc && (i + 1) * 2 < BUILD_ID_LEN; i++)
> > > +            snprintf(&info->build_id[i * 2], 3, "%02hhx",
> > > u.build_id[i]);
> > > +
> > > +        info->build_id[i*2]='\0';
> > > +    } else
> > > +        info->build_id = strdup("");
> > 
> > info->build_id is unconditionally leaked, given this patch.
> 
> It should be freed by libxl_version_info_dispose, which any correct callers
> should already be using.

This is a special case which is caching the result in the CTX, and the call
to dispose is actually in libxl_ctx_free not the caller, so the code is OK
but my "any correct callers" comment was bogus.

The caller can't/shouldn't call dispose because libxl_get_version_info
returns a const.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.