public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] nouveau: error paths leak in nvc0_graph_construct_context()
@ 2011-06-25  5:54 Dan Carpenter
  2011-06-25 12:08 ` [patch] nouveau: error paths leak in Ben Skeggs
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2011-06-25  5:54 UTC (permalink / raw)
  To: David Airlie
  Cc: kernel-janitors, Emil Velikov, Ben Skeggs, open list:DRM DRIVERS

Two of these error paths returned without freeing "ctx".

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/gpu/drm/nouveau/nvc0_graph.c b/drivers/gpu/drm/nouveau/nvc0_graph.c
index 39e9208..5aa3f9e 100644
--- a/drivers/gpu/drm/nouveau/nvc0_graph.c
+++ b/drivers/gpu/drm/nouveau/nvc0_graph.c
@@ -106,7 +106,8 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
 		if (!nv_wait(dev, 0x409800, 0x80000000, 0x80000000)) {
 			NV_ERROR(dev, "PGRAPH: HUB_SET_CHAN timeout\n");
 			nvc0_graph_ctxctl_debug(dev);
-			return -EBUSY;
+			ret = -EBUSY;
+			goto err;
 		}
 	} else {
 		nvc0_graph_load_context(chan);
@@ -119,10 +120,9 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
 	}
 
 	ret = nvc0_grctx_generate(chan);
-	if (ret) {
-		kfree(ctx);
-		return ret;
-	}
+	if (ret)
+		goto err;
+
 
 	if (!nouveau_ctxfw) {
 		nv_wr32(dev, 0x409840, 0x80000000);
@@ -131,14 +131,13 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
 		if (!nv_wait(dev, 0x409800, 0x80000000, 0x80000000)) {
 			NV_ERROR(dev, "PGRAPH: HUB_CTX_SAVE timeout\n");
 			nvc0_graph_ctxctl_debug(dev);
-			return -EBUSY;
+			ret = -EBUSY;
+			goto err;
 		}
 	} else {
 		ret = nvc0_graph_unload_context_to(dev, chan->ramin->vinst);
-		if (ret) {
-			kfree(ctx);
-			return ret;
-		}
+		if (ret)
+			goto err;
 	}
 
 	for (i = 0; i < priv->grctx_size; i += 4)
@@ -146,6 +145,10 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
 
 	priv->grctx_vals = ctx;
 	return 0;
+
+err:
+	kfree(ctx);
+	return ret;
 }
 
 static int

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] nouveau: error paths leak in
  2011-06-25  5:54 [patch] nouveau: error paths leak in nvc0_graph_construct_context() Dan Carpenter
@ 2011-06-25 12:08 ` Ben Skeggs
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Skeggs @ 2011-06-25 12:08 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Velikov, kernel-janitors, Emil, open list:DRM DRIVERS

On Sat, 2011-06-25 at 08:54 +0300, Dan Carpenter wrote:
> Two of these error paths returned without freeing "ctx".
Applied to nouveau git, thanks!

Ben.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/gpu/drm/nouveau/nvc0_graph.c b/drivers/gpu/drm/nouveau/nvc0_graph.c
> index 39e9208..5aa3f9e 100644
> --- a/drivers/gpu/drm/nouveau/nvc0_graph.c
> +++ b/drivers/gpu/drm/nouveau/nvc0_graph.c
> @@ -106,7 +106,8 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
>  		if (!nv_wait(dev, 0x409800, 0x80000000, 0x80000000)) {
>  			NV_ERROR(dev, "PGRAPH: HUB_SET_CHAN timeout\n");
>  			nvc0_graph_ctxctl_debug(dev);
> -			return -EBUSY;
> +			ret = -EBUSY;
> +			goto err;
>  		}
>  	} else {
>  		nvc0_graph_load_context(chan);
> @@ -119,10 +120,9 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
>  	}
>  
>  	ret = nvc0_grctx_generate(chan);
> -	if (ret) {
> -		kfree(ctx);
> -		return ret;
> -	}
> +	if (ret)
> +		goto err;
> +
>  
>  	if (!nouveau_ctxfw) {
>  		nv_wr32(dev, 0x409840, 0x80000000);
> @@ -131,14 +131,13 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
>  		if (!nv_wait(dev, 0x409800, 0x80000000, 0x80000000)) {
>  			NV_ERROR(dev, "PGRAPH: HUB_CTX_SAVE timeout\n");
>  			nvc0_graph_ctxctl_debug(dev);
> -			return -EBUSY;
> +			ret = -EBUSY;
> +			goto err;
>  		}
>  	} else {
>  		ret = nvc0_graph_unload_context_to(dev, chan->ramin->vinst);
> -		if (ret) {
> -			kfree(ctx);
> -			return ret;
> -		}
> +		if (ret)
> +			goto err;
>  	}
>  
>  	for (i = 0; i < priv->grctx_size; i += 4)
> @@ -146,6 +145,10 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
>  
>  	priv->grctx_vals = ctx;
>  	return 0;
> +
> +err:
> +	kfree(ctx);
> +	return ret;
>  }
>  
>  static int
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-25 12:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-25  5:54 [patch] nouveau: error paths leak in nvc0_graph_construct_context() Dan Carpenter
2011-06-25 12:08 ` [patch] nouveau: error paths leak in Ben Skeggs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox