Skip to content

Commit

Permalink
drivers/misc/sgi-gru: add return on error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sudip Mukherjee authored and Greg Kroah-Hartman committed Sep 21, 2015
1 parent bf84b14 commit a010d27
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/misc/sgi-gru/grukdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a010d27

Please sign in to comment.