From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323AbcAFS2p (ORCPT ); Wed, 6 Jan 2016 13:28:45 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:33211 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751863AbcAFS2n (ORCPT ); Wed, 6 Jan 2016 13:28:43 -0500 Subject: Re: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path To: Peter Senna Tschudin , thomas@winischhofer.net, gregkh@linuxfoundation.org, trivial@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <1452012850-6990-1-git-send-email-peter.senna@collabora.com> <1452012850-6990-5-git-send-email-peter.senna@collabora.com> Cc: Peter Senna Tschudin From: Sergei Shtylyov Message-ID: <568D5CD9.70704@cogentembedded.com> Date: Wed, 6 Jan 2016 21:28:41 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1452012850-6990-5-git-send-email-peter.senna@collabora.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 1/5/2016 7:54 PM, Peter Senna Tschudin wrote: > From: Peter Senna Tschudin > > This patch remove four calls to dev_err() from sisusb_probe() as > reporting memory allocation failures is redundant: > > - Remove a call to dev_err() that was reporting unsuccesful call to > kzalloc(). > > - Remove two calls to dev_err() that were reporting unsuccesful calls > to kmalloc(). > > - Remove a call to dev_err() that was reporting unsuccesful call to > kmalloc(), and replace it by code that clean up previously allocated > resources and abort the probe with -ENOMEM. Before this modification > sisusb->SiS_Pr could be dereferenced even it was null. I think the bug fix should be in its own patch. Don't intermix fixes with cleanups please. > Signed-off-by: Peter Senna Tschudin > --- > Tested by compilation only. > > drivers/usb/misc/sisusbvga/sisusb.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c > index 6cce4fb..875e365 100644 > --- a/drivers/usb/misc/sisusbvga/sisusb.c > +++ b/drivers/usb/misc/sisusbvga/sisusb.c [...] > /* Allocate our SiS_Pr */ > sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL); > if (!sisusb->SiS_Pr) { > - dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate SiS_Pr\n"); > + retval = -ENOMEM; > + goto error_4; > } > #endif > MBR, Sergei