Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1218497

Re: [PATCH v2 1/5] drivers/misc/sgi-gru: add return on error

From Dimitri Sivanich <sivanich@sgi.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/5] drivers/misc/sgi-gru: add return on error
Date 2015-09-03 20:30 +0200
Message-ID <q4HqO-37a-13@gated-at.bofh.it> (permalink)
References <q4E9z-6HN-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

On Thu, Sep 03, 2015 at 08:20:47PM +0530, Sudip Mukherjee wrote:
> If the buffer is too small then return the error and in the process
> remove the variables which became unused.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
> 
> v1: only removed variables.
> 
>  drivers/misc/sgi-gru/grukdump.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/misc/sgi-gru/grukdump.c b/drivers/misc/sgi-gru/grukdump.c
> index a3700a5..7e9aae5 100644
> --- a/drivers/misc/sgi-gru/grukdump.c
> +++ b/drivers/misc/sgi-gru/grukdump.c
> @@ -78,11 +78,10 @@ static int gru_dump_tfm(struct gru_state *gru,
>  		void __user *ubuf, void __user *ubufend)
>  {
>  	struct gru_tlb_fault_map *tfm;
> -	int i, ret, bytes;
> +	int i;
>  
> -	bytes = GRU_NUM_TFM * GRU_CACHE_LINE_BYTES;
> -	if (bytes > ubufend - ubuf)
> -		ret = -EFBIG;
> +	if (GRU_NUM_TFM * GRU_CACHE_LINE_BYTES > ubufend - ubuf)
> +		return -EFBIG;
>  
>  	for (i = 0; i < GRU_NUM_TFM; i++) {
>  		tfm = get_tfm(gru->gs_gru_base_vaddr, i);
> @@ -99,11 +98,10 @@ static int gru_dump_tgh(struct gru_state *gru,
>  		void __user *ubuf, void __user *ubufend)
>  {
>  	struct gru_tlb_global_handle *tgh;
> -	int i, ret, bytes;
> +	int i;
>  
> -	bytes = GRU_NUM_TGH * GRU_CACHE_LINE_BYTES;
> -	if (bytes > ubufend - ubuf)
> -		ret = -EFBIG;
> +	if (GRU_NUM_TGH * GRU_CACHE_LINE_BYTES > ubufend - ubuf)
> +		return -EFBIG;
>  
>  	for (i = 0; i < GRU_NUM_TGH; i++) {
>  		tgh = get_tgh(gru->gs_gru_base_vaddr, i);
> -- 
> 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/5] drivers/misc/sgi-gru: add return on error Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-03 17:00 +0200
  [PATCH v2 4/5] drivers/misc/sgi-gru: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-03 17:00 +0200
    Re: [PATCH v2 4/5] drivers/misc/sgi-gru: fix dereference of ERR_PTR Dimitri Sivanich <sivanich@sgi.com> - 2015-09-03 20:50 +0200
    [PATCH v3] drivers/misc/sgi-gru: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-04 06:30 +0200
      Re: [PATCH v3] drivers/misc/sgi-gru: fix dereference of ERR_PTR Dimitri Sivanich <sivanich@sgi.com> - 2015-09-04 15:00 +0200
  Re: [PATCH v2 1/5] drivers/misc/sgi-gru: add return on error Dimitri Sivanich <sivanich@sgi.com> - 2015-09-03 20:30 +0200

csiph-web