[patch] vmd: fix possible small memleak in vm_claimid() error path

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] vmd: fix possible small memleak in vm_claimid() error path

Hiltjo Posthuma
Hi,

This fixes a small possible memory leak in an error handling path in vmd.c
vm_claimid().


diff --git usr.sbin/vmd/vmd.c usr.sbin/vmd/vmd.c
index 654af5974d3..81be6b356d6 100644
--- usr.sbin/vmd/vmd.c
+++ usr.sbin/vmd/vmd.c
@@ -1197,6 +1197,7 @@ vm_claimid(const char *name, int uid, uint32_t *id)
  n2i->uid = uid;
  if (strlcpy(n2i->name, name, sizeof(n2i->name)) >= sizeof(n2i->name)) {
  log_warnx("vm name too long");
+ free(n2i);
  return -1;
  }
  TAILQ_INSERT_TAIL(env->vmd_known, n2i, entry);

--
Kind regards,
Hiltjo

Reply | Threaded
Open this post in threaded view
|

Re: [patch] vmd: fix possible small memleak in vm_claimid() error path

Mike Larkin-2
On Thu, Aug 29, 2019 at 07:43:31PM +0200, Hiltjo Posthuma wrote:

> Hi,
>
> This fixes a small possible memory leak in an error handling path in vmd.c
> vm_claimid().
>
>
> diff --git usr.sbin/vmd/vmd.c usr.sbin/vmd/vmd.c
> index 654af5974d3..81be6b356d6 100644
> --- usr.sbin/vmd/vmd.c
> +++ usr.sbin/vmd/vmd.c
> @@ -1197,6 +1197,7 @@ vm_claimid(const char *name, int uid, uint32_t *id)
>   n2i->uid = uid;
>   if (strlcpy(n2i->name, name, sizeof(n2i->name)) >= sizeof(n2i->name)) {
>   log_warnx("vm name too long");
> + free(n2i);
>   return -1;
>   }
>   TAILQ_INSERT_TAIL(env->vmd_known, n2i, entry);
>
> --
> Kind regards,
> Hiltjo
>

Thanks, committed.

-ml