[libvirt] [PATCH] Fix Memory Leak in daemon/libvirtd.c
Ján Tomko
jtomko at redhat.com
Fri Apr 4 06:19:42 UTC 2014
On 04/03/2014 08:13 PM, Nehal J Wani wrote:
> Fixes leak introduced by e562e82f
>
> ==4937== 64 bytes in 1 blocks are definitely lost in loss record 270 of 405
> ==4937== at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
> ==4937== by 0x6FA41C4: __vasprintf_chk (vasprintf_chk.c:90)
> ==4937== by 0x50C8D29: virVasprintfInternal (stdio2.h:199)
> ==4937== by 0x50C8E3A: virAsprintfInternal (virstring.c:362)
> ==4937== by 0x11D01A: main (libvirtd.c:1170)
>
> ---
> daemon/libvirtd.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
> index e247259..bb84c90 100644
> --- a/daemon/libvirtd.c
> +++ b/daemon/libvirtd.c
> @@ -1132,6 +1132,7 @@ int main(int argc, char **argv) {
> bool privileged = geteuid() == 0 ? true : false;
> bool implicit_conf = false;
> char *run_dir = NULL;
> + char *cpumap = NULL;
> mode_t old_umask;
>
> struct option opts[] = {
> @@ -1159,7 +1160,6 @@ int main(int argc, char **argv) {
> if (strstr(argv[0], "lt-libvirtd") ||
> strstr(argv[0], "/daemon/.libs/libvirtd")) {
> char *tmp = strrchr(argv[0], '/');
> - char *cpumap;
There is no need to move the declaration or initialize it to NULL, since it's
always declared and initialized when we get to the VIR_FREE below and we don't
have cleanup paths here.
> if (!tmp) {
> fprintf(stderr, _("%s: cannot identify driver directory\n"), argv[0]);
> exit(EXIT_FAILURE);
> @@ -1182,6 +1182,7 @@ int main(int argc, char **argv) {
> virDriverModuleInitialize(driverdir);
> #endif
> cpuMapOverride(cpumap);
> + VIR_FREE(cpumap);
> *tmp = '/';
> /* Must not free 'driverdir' - it is still used */
> }
>
ACK and pushed, thank you for the patch!
Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140404/d2229820/attachment-0001.sig>
More information about the libvir-list
mailing list