Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5223899imw; Wed, 20 Jul 2022 01:13:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1shzBI5vUkR9WfEsVFv8eamYK2F0QQyJKeW1sTpJfEPOFidtjbQlHfwhuTSUxgZF/U7Alxh X-Received: by 2002:a17:907:2dab:b0:72f:f7:bdd6 with SMTP id gt43-20020a1709072dab00b0072f00f7bdd6mr23629378ejc.330.1658304785263; Wed, 20 Jul 2022 01:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658304785; cv=none; d=google.com; s=arc-20160816; b=MhhvAVe9p0baM4OVmvU97YxZBsYmG8FY0jrHAa9vFIuV1epWgbBO+SStCm5MQHG0gW LGqgmn41xJs3bBtCJo+0QWAtg/05jQW6YobF43Xa3woB7yfAnr9B+m7BrsJBRo8Miw74 HWtpCvXWZ54F7R/KdRspwvZ6b8hJRirXn2MPlGr8dVeauJhwHR2L/w9uGa+YgOZ3kMg7 jp6OESY4XdFQUcvIi7m9jSEX0a+gBeOrq7JTXG38FR9NRV6EEZu2j/eu2JxvD8bgx9Gb UxCPM4t/O26tr/jjDo+iJCD/9+EnL64Wnb310iBwSNaudyk6Duf0hOygxicrIXFxk71/ XElg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=9pzIaywsrW6mzjuLrOhiAtnNhJCIlWK/MPAipzi92YU=; b=ttsQzBeqVBXl1hlu1OdqSdMgkOCY3FUJ9uia6Oix3LK08IiATYpqSOm0umC6RwbRLn uXIGg8EzybBJLatn4ydwVt+ukN2jQ5+Evgup412SWkivPRFrZhstC3OdH3I8bUuvX/tI SAz0DSeCM7JRHYvg6QxV+I6Zd6vXBIz76A3EkuyvreoLk1fIQ3dhuMM4PZ3ve/mTHOpz iG4VrcubaRDcig7rr1XCV4HYWblS3tSq1hnNrihHckRgyjxYdgJg7gA+lb1aUkso5P8u 2iRCkRd0xvUIc1CRKEE0utgaaeA0E5RbplalfLKOhr/YBa+Wlpo2GOBn1RCqKl5O/UWB s+Ig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020a056402348300b00435c7cf30d4si25014245edc.27.2022.07.20.01.12.40; Wed, 20 Jul 2022 01:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239323AbiGTHq5 (ORCPT + 99 others); Wed, 20 Jul 2022 03:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240212AbiGTHqh (ORCPT ); Wed, 20 Jul 2022 03:46:37 -0400 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4DE3F301 for ; Wed, 20 Jul 2022 00:46:33 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id E4PdoAiFbnm5hE4PdoE8PB; Wed, 20 Jul 2022 09:46:31 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 20 Jul 2022 09:46:31 +0200 X-ME-IP: 90.11.190.129 Message-ID: <604f2d3f-659c-3312-d69f-c133aec275ca@wanadoo.fr> Date: Wed, 20 Jul 2022 09:46:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] usb: trancevibrator: simplify tv_probe Content-Language: en-US To: dzm91@hust.edu.cn Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mudongliangabcd@gmail.com References: <20220720072346.33511-1-dzm91@hust.edu.cn> From: Christophe JAILLET In-Reply-To: <20220720072346.33511-1-dzm91@hust.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 20/07/2022 à 09:23, Dongliang Mu a écrit : > From: Dongliang Mu > > The function tv_probe does not need to invoke kfree when the > allocation fails. So let's simplify the code of tv_probe. > Another change is to remove a redundant space. > > Signed-off-by: Dongliang Mu > --- > drivers/usb/misc/trancevibrator.c | 13 +++---------- > 1 file changed, 3 insertions(+), 10 deletions(-) > > diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c > index 26baba3ab7d7..30d4d774d448 100644 > --- a/drivers/usb/misc/trancevibrator.c > +++ b/drivers/usb/misc/trancevibrator.c > @@ -84,29 +84,22 @@ static int tv_probe(struct usb_interface *interface, > { > struct usb_device *udev = interface_to_usbdev(interface); > struct trancevibrator *dev; > - int retval; > > dev = kzalloc(sizeof(struct trancevibrator), GFP_KERNEL); > - if (!dev) { > - retval = -ENOMEM; > - goto error; > - } > + if (!dev) > + return -ENOMEM; > > dev->udev = usb_get_dev(udev); > usb_set_intfdata(interface, dev); > > return 0; Hi, looks like: error: kfree(dev); return retval; at the end of the function can be removed as-well. Just my 2c. CJ