Skip to contentSkip to conversation

radeon: small memory leak

PATCH In review Dan Carpenter 2 participants 2 messages Apr 6, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 radeon: small memory leak

This is an unlikely memory leak, but we may as well fix it. It's easy to fix and every static checker will complain if we don't.

drivers/gpu/drm/radeon/atom.c +5 -2
index 247f8ee..58845e0 100644
@@ -1136,6 +1136,7 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
 	int len, ws, ps, ptr;
 	unsigned char op;
 	atom_exec_context ectx;
+	int ret = 0;
 
 	if (!base)
 		return -EINVAL;
@@ -1168,7 +1169,8 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
 		if (ectx.abort) {
 			DRM_ERROR("atombios stuck executing %04X (len %d, WS %d, PS %d) @ 0x%04X\n",
 				base, len, ws, ps, ptr - 1);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free;
 		}
 
 		if (op < ATOM_OP_CNT && op > 0)
@@ -1183,9 +1185,10 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
 	debug_depth--;
 	SDEBUG("<<\n");
 
+free:
 	if (ws)
 		kfree(ectx.ws);
-	return 0;
+	return ret;
 }
 
 int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Dan Carpenter

This is an unlikely memory leak, but we may as well fix it.  It's easy to fix and every static checker will complain if we don't.

drivers/gpu/drm/radeon/atom.c +3 -1
index 247f8ee..58845e0 100644
@@ -1136,6 +1136,7 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
        int len, ws, ps, ptr;
        unsigned char op;
        atom_exec_context ectx;
+       int ret = 0;
 
        if (!base)
                return -EINVAL;
@@ -1168,7 +1169,8 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
                if (ectx.abort) {
                        DRM_ERROR("atombios stuck executing %04X (len %d, WS %d, PS %d) @ 0x%04X\n",
                                base, len, ws, ps, ptr - 1);
-                       return -EINVAL;
+                       ret = -EINVAL;
+                       goto free;
                }
 
                if (op < ATOM_OP_CNT && op > 0)
@@ -1183,9 +1185,10 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
        debug_depth--;

drivers/gpu/drm/radeon/atom.c static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32 · line 1194

Quoted 10 lines
drivers/gpu/drm/radeon/atom.c +2 -1
        SDEBUG("<<\n");
 
+free:
        if (ws)
                kfree(ectx.ws);
-       return 0;
+       return ret;
  }
 
  int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)

Looks good.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--