From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935206AbcA0XmQ (ORCPT ); Wed, 27 Jan 2016 18:42:16 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36402 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932516AbcA0XmM (ORCPT ); Wed, 27 Jan 2016 18:42:12 -0500 Date: Wed, 27 Jan 2016 15:42:09 -0800 From: Dmitry Torokhov To: Aniroop Mathur Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, aniroop.mathur@gmail.com Subject: Re: [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client Message-ID: <20160127234209.GF28687@dtor-ws> References: <1453744205-868-1-git-send-email-a.mathur@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1453744205-868-1-git-send-email-a.mathur@samsung.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 Hi Aniroop, On Mon, Jan 25, 2016 at 11:20:05PM +0530, Aniroop Mathur wrote: > Lets fix twice checking of memory allocation failure of evdev_client > structure when allocated successfully. I think compiler will take care of optimizing away the 2nd check, so I'd leave the code as is. Thanks. > > Signed-off-by: Aniroop Mathur > --- > drivers/input/evdev.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c > index e9ae3d5..102b5d9 100644 > --- a/drivers/input/evdev.c > +++ b/drivers/input/evdev.c > @@ -503,10 +503,11 @@ static int evdev_open(struct inode *inode, struct file *file) > int error; > > client = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); > - if (!client) > + if (!client) { > client = vzalloc(size); > - if (!client) > - return -ENOMEM; > + if (!client) > + return -ENOMEM; > + } > > client->bufsize = bufsize; > spin_lock_init(&client->buffer_lock); > -- > 2.6.2 > -- Dmitry