PATCH xserver small memory leaks fixes

Hans de Goede hdegoede at redhat.com
Fri Sep 23 11:56:40 UTC 2016


Hi David,

On 05/05/2016 10:39 AM, David CARLIER wrote:
> Hi all,
>
> This is a small patch to fix couple of small memory leaks.
>
> Hope it s useful.

It is thanks for your patch, I've split 2 bits out into small patches
and I've dropped the os/rpcauth.c change I think that you are doing
the right thing there, but I'm not 100% sure (and if doing the free
is the right thing, it also needs to happen in the success path,
not just in the failure path).

You can see the split out patches here:

https://cgit.freedesktop.org/~jwrdegoede/xserver

I'm waiting for review from another developer for the 2 bits I
split out, the main patch will be included in my next pull-request
to get a bunch of fixes added to the xserver for 1.19

Regards,

Hans



>
> Thanks.
>
> Kind regards.
>
>>From 88024a5d4f36902ae66fe854d8ec93c3ed71cf8a Mon Sep 17 00:00:00 2001
> From: David Carlier <devnexen at gmail.com>
> Date: Wed, 4 May 2016 22:03:19 +0100
> Subject: [PATCH xserver] couple of memory leaks fixes and avoiding bit
>  shifting on an unitialized value.
>
> ---
>  Xext/shm.c                              | 1 +
>  Xext/vidmode.c                          | 5 +++--
>  composite/compext.c                     | 8 ++++++--
>  hw/xfree86/ddc/ddc.c                    | 2 +-
>  hw/xfree86/drivers/modesetting/driver.c | 1 +
>  hw/xfree86/utils/gtf/gtf.c              | 2 ++
>  os/rpcauth.c                            | 1 +
>  7 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/Xext/shm.c b/Xext/shm.c
> index b359a90..a63b42c 100644
> --- a/Xext/shm.c
> +++ b/Xext/shm.c
> @@ -975,6 +975,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
>                                RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess);
>              if (result != Success) {
>                  pDraw->pScreen->DestroyPixmap(pMap);
> +		 free(newPix);
>                  return result;
>              }
>              dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
> diff --git a/Xext/vidmode.c b/Xext/vidmode.c
> index 499a2a8..65ce20b 100644
> --- a/Xext/vidmode.c
> +++ b/Xext/vidmode.c
> @@ -1315,7 +1315,7 @@ ProcVidModeGetDotClocks(ClientPtr client)
>      int n;
>      int numClocks;
>      CARD32 dotclock;
> -    int *Clocks = NULL;
> +    int *Clocks = NULL, *Ptr;
>      Bool ClockProg;
>
>      DEBUG_P("XF86VidModeGetDotClocks");
> @@ -1361,6 +1361,7 @@ ProcVidModeGetDotClocks(ClientPtr client)
>          swapl(&rep.maxclocks);
>          swapl(&rep.flags);
>      }
> +    Ptr = Clocks;
>      WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep);
>      if (!ClockProg) {
>          for (n = 0; n < numClocks; n++) {
> @@ -1374,7 +1375,7 @@ ProcVidModeGetDotClocks(ClientPtr client)
>          }
>      }
>
> -    free(Clocks);
> +    free(Ptr);
>      return Success;
>  }
>
> diff --git a/composite/compext.c b/composite/compext.c
> index f1a8255..96d07d7 100644
> --- a/composite/compext.c
> +++ b/composite/compext.c
> @@ -762,14 +762,18 @@ PanoramiXCompositeNameWindowPixmap(ClientPtr client)
>              return BadMatch;
>          }
>
> -        if (!AddResource(newPix->info[i].id, RT_PIXMAP, (void *) pPixmap))
> +        if (!AddResource(newPix->info[i].id, RT_PIXMAP, (void *) pPixmap)) {
> +	     free(newPix);
>              return BadAlloc;
> +	}
>
>          ++pPixmap->refcnt;
>      }
>
> -    if (!AddResource(stuff->pixmap, XRT_PIXMAP, (void *) newPix))
> +    if (!AddResource(stuff->pixmap, XRT_PIXMAP, (void *) newPix)) {
> +	 free(newPix);
>          return BadAlloc;
> +    }
>
>      return Success;
>  }
> diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
> index ee533db..b82dfc1 100644
> --- a/hw/xfree86/ddc/ddc.c
> +++ b/hw/xfree86/ddc/ddc.c
> @@ -149,7 +149,7 @@ GetEDID_DDC1(unsigned int *s_ptr)
>          return NULL;
>      s_end = s_ptr + NUM;
>      s_pos = s_ptr + s_start;
> -    d_block = malloc(EDID1_LEN);
> +    d_block = calloc(1, EDID1_LEN);
>      if (!d_block)
>          return NULL;
>      d_pos = d_block;
> diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
> index fe5d5e1..0a0ca65 100644
> --- a/hw/xfree86/drivers/modesetting/driver.c
> +++ b/hw/xfree86/drivers/modesetting/driver.c
> @@ -761,6 +761,7 @@ ms_get_drm_master_fd(ScrnInfoPtr pScrn)
>                  );
>          }
>          ms->fd = drmOpen(NULL, BusID);
> +	 free(BusID);
>      }
>      else {
>          const char *devicename;
> diff --git a/hw/xfree86/utils/gtf/gtf.c b/hw/xfree86/utils/gtf/gtf.c
> index e88387d..c31bc8f 100644
> --- a/hw/xfree86/utils/gtf/gtf.c
> +++ b/hw/xfree86/utils/gtf/gtf.c
> @@ -692,6 +692,8 @@ main(int argc, char *argv[])
>      if (o->fbmode)
>          print_fb_mode(m);
>
> +    free(m);
> +
>      return 0;
>
>  }
> diff --git a/os/rpcauth.c b/os/rpcauth.c
> index 5680489..923ffc3 100644
> --- a/os/rpcauth.c
> +++ b/os/rpcauth.c
> @@ -111,6 +111,7 @@ authdes_ezdecode(const char *inmsg, int len)
>   bad2:
>      free(r.rq_clntcred);
>   bad1:
> +    free(temp_inmsg);
>      return ((char *) 0);        /* ((struct authdes_cred *) NULL); */
>  }
>
>


More information about the xorg-devel mailing list