[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [libvirt] Memory leak of the remoteDomainSet* functions
- From: Matthias Bolte <matthias bolte googlemail com>
- To: Osier Yang <jyang redhat com>
- Cc: "libvir-list redhat com" <libvir-list redhat com>
- Subject: Re: [libvirt] Memory leak of the remoteDomainSet* functions
- Date: Wed, 27 Jul 2011 16:26:23 +0200
2011/7/27 Osier Yang <jyang redhat com>:
> Hello, there
>
> Per bug https://bugzilla.redhat.com/show_bug.cgi?id=725322, should
> we change the remoteDomainSet* functions into "skipgen", and fix the
> leaks like below? (NB, new VIR_FREE statements)
Why not fix the generator instead?
> static int
> remoteDomainSetBlkioParameters(virDomainPtr dom,
> virTypedParameterPtr params,
> int nparams,
> unsigned int flags)
> {
> int rv = -1;
> int i;
> struct private_data *priv = dom->conn->privateData;
> remote_domain_set_blkio_parameters_args args;
> remote_domain_set_blkio_parameters_args args;
>
> remoteDriverLock(priv);
>
> make_nonnull_domain(&args.dom, dom);
> args.flags = flags;
>
> if (remoteSerializeTypedParameters(params,
> nparams,
> &args.params.params_val,
> &args.params.params_len) < 0) {
> for (i = 0; i < nparams; i++) {
> VIR_FREE(args.params.params_val[i].field);
> }
> VIR_FREE(args.params.params_val);
This loop should not be needed as remoteSerializeTypedParameters
cleans up in the error case.
> xdr_free((xdrproc_t)xdr_remote_domain_set_blkio_parameters_args, (char
> *)&args);
> goto done;
> }
>
> if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS,
> (xdrproc_t)xdr_remote_domain_set_blkio_parameters_args, (char *)&args,
> (xdrproc_t)xdr_void, (char *)NULL) == -1) {
> goto done;
> }
>
> rv = 0;
>
> done:
> if (args.params.params_val) {
> for (i = 0; i < nparams; i++) {
> VIR_FREE(args.params.params_val[i].field);
> }
> VIR_FREE(args.params.params_val);
> }
> remoteDriverUnlock(priv);
> return rv;
> }
This can be fixed in the generator, but why no use xdr_free here
instead of open coding the free loop?
--
Matthias Bolte
http://photron.blogspot.com
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]