]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drivers/misc/sgi-gru: add return on error
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Thu, 3 Sep 2015 14:50:47 +0000 (20:20 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Sep 2015 02:27:58 +0000 (19:27 -0700)
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>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/sgi-gru/grukdump.c

index a3700a56b8ff677d4b972de099ef6cde5b49ea9a..7e9aae56b72eb06e1ba225b1cb87aecf91c0762e 100644 (file)
@@ -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);