[PATCH] - Fix Unchecked memory usage.

Jeremy Huddleston jeremyhu at freedesktop.org
Wed Jul 8 08:53:50 PDT 2009


Maarten Maathuis wrote:
> Imagine what happens if everyone sent links. A patch is forgotten or
> maybe it's part a larger discussion. Suddenly the link dies, and part
> of the history is gone. It's really annoying to check mailinglist
> archives only to find dead links.
>
> Maarten.
>   

And it makes quoting in a reply easier...

You don't need to initialize bufmgr_gem to NULL here since the first
thing you do is call calloc() for it... of course any decent optimized
compiler will simply ignore that '= NULL', but I figured I'd point it out.

@@ -1389,13 +1395,16 @@ drm_intel_gem_bo_disable_reuse(drm_intel_bo *bo)
 drm_intel_bufmgr *
 drm_intel_bufmgr_gem_init(int fd, int batch_size)
 {
-    drm_intel_bufmgr_gem *bufmgr_gem;
+    drm_intel_bufmgr_gem *bufmgr_gem = NULL;
     struct drm_i915_gem_get_aperture aperture;
     drm_i915_getparam_t gp;
     int ret, i;
     unsigned long size;
 
     bufmgr_gem = calloc(1, sizeof(*bufmgr_gem));
+    if (bufmgr_gem == NULL) {
+        return NULL;
+    }
     bufmgr_gem->fd = fd;
 
     if (pthread_mutex_init(&bufmgr_gem->lock, NULL) != 0) {




More information about the xorg-devel mailing list