All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 1/2] gru: unlocking should be conditional in gru_dump_context()
@ 2014-01-30 12:10 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-01-30 12:10 UTC (permalink / raw)
  To: Dimitri Sivanich; +Cc: linux-kernel, kernel-janitors

I was reviewing this and noticed that unlocking should be conditional on
the error path.  I've changed it to unlock and return directly since we
only do it once and it seems unlikely to change in the near future.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/misc/sgi-gru/grukdump.c b/drivers/misc/sgi-gru/grukdump.c
index 9b2062d17327..2bef3f76032a 100644
--- a/drivers/misc/sgi-gru/grukdump.c
+++ b/drivers/misc/sgi-gru/grukdump.c
@@ -139,8 +139,11 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
 
 	ubuf += sizeof(hdr);
 	ubufcch = ubuf;
-	if (gru_user_copy_handle(&ubuf, cch))
-		goto fail;
+	if (gru_user_copy_handle(&ubuf, cch)) {
+		if (cch_locked)
+			unlock_cch_handle(cch);
+		return -EFAULT;
+	}
 	if (cch_locked)
 		ubufcch->delresp = 0;
 	bytes = sizeof(hdr) + GRU_CACHE_LINE_BYTES;
@@ -179,10 +182,6 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
 		ret = -EFAULT;
 
 	return ret ? ret : bytes;
-
-fail:
-	unlock_cch_handle(cch);
-	return -EFAULT;
 }
 
 int gru_dump_chiplet_request(unsigned long arg)

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

* [patch 1/2] gru: unlocking should be conditional in gru_dump_context()
@ 2014-01-30 12:10 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-01-30 12:10 UTC (permalink / raw)
  To: Dimitri Sivanich; +Cc: linux-kernel, kernel-janitors

I was reviewing this and noticed that unlocking should be conditional on
the error path.  I've changed it to unlock and return directly since we
only do it once and it seems unlikely to change in the near future.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/misc/sgi-gru/grukdump.c b/drivers/misc/sgi-gru/grukdump.c
index 9b2062d17327..2bef3f76032a 100644
--- a/drivers/misc/sgi-gru/grukdump.c
+++ b/drivers/misc/sgi-gru/grukdump.c
@@ -139,8 +139,11 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
 
 	ubuf += sizeof(hdr);
 	ubufcch = ubuf;
-	if (gru_user_copy_handle(&ubuf, cch))
-		goto fail;
+	if (gru_user_copy_handle(&ubuf, cch)) {
+		if (cch_locked)
+			unlock_cch_handle(cch);
+		return -EFAULT;
+	}
 	if (cch_locked)
 		ubufcch->delresp = 0;
 	bytes = sizeof(hdr) + GRU_CACHE_LINE_BYTES;
@@ -179,10 +182,6 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
 		ret = -EFAULT;
 
 	return ret ? ret : bytes;
-
-fail:
-	unlock_cch_handle(cch);
-	return -EFAULT;
 }
 
 int gru_dump_chiplet_request(unsigned long arg)

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

* Re: [patch 1/2] gru: unlocking should be conditional in gru_dump_context()
  2014-01-30 12:10 ` Dan Carpenter
@ 2014-01-30 14:01   ` Dimitri Sivanich
  -1 siblings, 0 replies; 4+ messages in thread
From: Dimitri Sivanich @ 2014-01-30 14:01 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-kernel, kernel-janitors

Acked-by: Dimitri Sivanich <sivanich@sgi.com>

On Thu, Jan 30, 2014 at 03:10:44PM +0300, Dan Carpenter wrote:
> I was reviewing this and noticed that unlocking should be conditional on
> the error path.  I've changed it to unlock and return directly since we
> only do it once and it seems unlikely to change in the near future.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/misc/sgi-gru/grukdump.c b/drivers/misc/sgi-gru/grukdump.c
> index 9b2062d17327..2bef3f76032a 100644
> --- a/drivers/misc/sgi-gru/grukdump.c
> +++ b/drivers/misc/sgi-gru/grukdump.c
> @@ -139,8 +139,11 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
>  
>  	ubuf += sizeof(hdr);
>  	ubufcch = ubuf;
> -	if (gru_user_copy_handle(&ubuf, cch))
> -		goto fail;
> +	if (gru_user_copy_handle(&ubuf, cch)) {
> +		if (cch_locked)
> +			unlock_cch_handle(cch);
> +		return -EFAULT;
> +	}
>  	if (cch_locked)
>  		ubufcch->delresp = 0;
>  	bytes = sizeof(hdr) + GRU_CACHE_LINE_BYTES;
> @@ -179,10 +182,6 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
>  		ret = -EFAULT;
>  
>  	return ret ? ret : bytes;
> -
> -fail:
> -	unlock_cch_handle(cch);
> -	return -EFAULT;
>  }
>  
>  int gru_dump_chiplet_request(unsigned long arg)

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

* Re: [patch 1/2] gru: unlocking should be conditional in gru_dump_context()
@ 2014-01-30 14:01   ` Dimitri Sivanich
  0 siblings, 0 replies; 4+ messages in thread
From: Dimitri Sivanich @ 2014-01-30 14:01 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-kernel, kernel-janitors

Acked-by: Dimitri Sivanich <sivanich@sgi.com>

On Thu, Jan 30, 2014 at 03:10:44PM +0300, Dan Carpenter wrote:
> I was reviewing this and noticed that unlocking should be conditional on
> the error path.  I've changed it to unlock and return directly since we
> only do it once and it seems unlikely to change in the near future.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/misc/sgi-gru/grukdump.c b/drivers/misc/sgi-gru/grukdump.c
> index 9b2062d17327..2bef3f76032a 100644
> --- a/drivers/misc/sgi-gru/grukdump.c
> +++ b/drivers/misc/sgi-gru/grukdump.c
> @@ -139,8 +139,11 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
>  
>  	ubuf += sizeof(hdr);
>  	ubufcch = ubuf;
> -	if (gru_user_copy_handle(&ubuf, cch))
> -		goto fail;
> +	if (gru_user_copy_handle(&ubuf, cch)) {
> +		if (cch_locked)
> +			unlock_cch_handle(cch);
> +		return -EFAULT;
> +	}
>  	if (cch_locked)
>  		ubufcch->delresp = 0;
>  	bytes = sizeof(hdr) + GRU_CACHE_LINE_BYTES;
> @@ -179,10 +182,6 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
>  		ret = -EFAULT;
>  
>  	return ret ? ret : bytes;
> -
> -fail:
> -	unlock_cch_handle(cch);
> -	return -EFAULT;
>  }
>  
>  int gru_dump_chiplet_request(unsigned long arg)

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

end of thread, other threads:[~2014-01-30 14:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-30 12:10 [patch 1/2] gru: unlocking should be conditional in gru_dump_context() Dan Carpenter
2014-01-30 12:10 ` Dan Carpenter
2014-01-30 14:01 ` Dimitri Sivanich
2014-01-30 14:01   ` Dimitri Sivanich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.