Commit a010d276 authored by Sudip Mukherjee's avatar Sudip Mukherjee Committed by Greg Kroah-Hartman

drivers/misc/sgi-gru: add return on error

If the buffer is too small then return the error and in the process
remove the variables which became unused.
Signed-off-by: default avatarSudip Mukherjee <sudip@vectorindia.org>
Acked-by: default avatarDimitri Sivanich <sivanich@sgi.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bf84b140
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment