From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932557AbbICSVm (ORCPT ); Thu, 3 Sep 2015 14:21:42 -0400 Received: from relay3.sgi.com ([192.48.152.1]:37986 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932473AbbICSVl (ORCPT ); Thu, 3 Sep 2015 14:21:41 -0400 Date: Thu, 3 Sep 2015 13:21:38 -0500 From: Dimitri Sivanich To: Sudip Mukherjee Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/5] drivers/misc/sgi-gru: add return on error Message-ID: <20150903182138.GA4319@sgi.com> References: <1441291851-29411-1-git-send-email-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441291851-29411-1-git-send-email-sudipm.mukherjee@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Acked-by: Dimitri Sivanich 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 > --- > > 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