Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6753560iob; Wed, 11 May 2022 04:47:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsOqq0f09ANzp35kE/SOfDi2nyoTlj6QWS2yQFJaahIMxKCQP1OjeAxEPrQnO+hmIKKiSR X-Received: by 2002:a17:907:720f:b0:6f8:5e72:d8d8 with SMTP id dr15-20020a170907720f00b006f85e72d8d8mr18341684ejc.541.1652269655380; Wed, 11 May 2022 04:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652269655; cv=none; d=google.com; s=arc-20160816; b=UmWX2uMsOWjlw2Z9SZZ4MuFFhASNcMeQVzlSNVGQbWh2icC+k+o1xwRk3QpzEFWKPc TDzAFSQLB95sZP2ve6e8g7q0f532Tt0g+qabjp/wrpHai+mVl4KhsEXLuuASlikVutGl 2KYusHaSAIEpdJ+PzTBTWhgl1/4E8/haoVYIRRJ7OQpOY6ahsbqh5DfmD3131cmghH+0 tkQlvnhQ3jxUWGkYMHeLHLq6exOXnLRw0dgqUE1NKBsSxZlD/nMcDV0ZM5BapMJeFIsM r5xVN1s4PfIACiDK2aF3hKbA07XJd9wHoJE+/A5DI4hSFr3wSQgoYfl4FYGa+fuQisvd 5Org== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fk8u5AGQ8sLFqRxY/eOEMyiP5KY3UYCV1pFG2YEt/5Q=; b=dQsXurnXdKP2R1ZI/RTNNzqu4cvvR6tdT+GTjP8hfySDmbyJH5SpNMm3MF+EdHQDHZ htvlf+opbFPrO9QaDTF+NFOVbM1e9GuJSKlAbCW3XeGuZ7+pQPOxv78zmJUdQ9Wbsd33 Hv6Tm/hIbjTp4l4pi2TA68UHEx3bcnPyR4kAh4WN32ZGe0z3I5hcszoyTF9hOOX2XjyB OdYj5XgbdE/VBRr3hR09pveaCHduLJvNk0cvuv1A213zUnr9e+4to2zgpEHkZQsnPKZw uPQtrbJJs95/glD9Q1l8qdQPD7SKW+UzFc8pi8ddd3+IW2zdMPZpG+kVvQQ6SOIvwOpw T0Cg== 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 dp5-20020a170906c14500b006f4fe0e5576si2563678ejc.34.2022.05.11.04.47.09; Wed, 11 May 2022 04:47:35 -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 S242091AbiEKIr0 (ORCPT + 99 others); Wed, 11 May 2022 04:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235410AbiEKIrX (ORCPT ); Wed, 11 May 2022 04:47:23 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0096674D1 for ; Wed, 11 May 2022 01:47:22 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nohzx-000642-LL; Wed, 11 May 2022 10:47:09 +0200 Received: from pengutronix.de (unknown [IPv6:2a01:4f8:1c1c:29e9:22:41ff:fe00:1400]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 4AF667B9AC; Wed, 11 May 2022 08:47:06 +0000 (UTC) Date: Wed, 11 May 2022 10:47:05 +0200 From: Marc Kleine-Budde To: Vincent MAILHOL Cc: z , Wolfgang Grandegger , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Stefan =?utf-8?B?TcOkdGpl?= , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bernard@vivo.com Subject: Re: [PATCH] usb/peak_usb: cleanup code Message-ID: <20220511084705.zh5fdetggullt75i@pengutronix.de> References: <20220511063850.649012-1-zhaojunkui2008@126.com> <20220511064450.phisxc7ztcc3qkpj@pengutronix.de> <4986975d.3de3.180b1f57189.Coremail.zhaojunkui2008@126.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kn225256pnovgin4" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 --kn225256pnovgin4 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 11.05.2022 17:28:26, Vincent MAILHOL wrote: > On Wed. 11 May 2022 at 16:11, z wrote: > > At 2022-05-11 14:44:50, "Marc Kleine-Budde" wrote: > > >On 10.05.2022 23:38:38, Bernard Zhao wrote: > > >> The variable fi and bi only used in branch if (!dev->prev_siblings) > > >> , fi & bi not kmalloc in else branch, so move kfree into branch > > >> if (!dev->prev_siblings),this change is to cleanup the code a bit. > > > > > >Please move the variable declaration into that scope, too. Adjust the > > >error handling accordingly. > > > > Hi Marc: > > > > I am not sure if there is some gap. > > If we move the variable declaration into that scope, then each error br= anch has to do the kfree job, like: > > if (err) { > > dev_err(dev->netdev->dev.parent, > > "unable to read %s firmware info (err %= d)\n", > > pcan_usb_pro.name, err); > > kfree(bi); > > kfree(fi); > > kfree(usb_if); > > > > return err; > > } > > I am not sure if this looks a little less clear? > > Thanks! >=20 > A cleaner way would be to move all the content of the if > (!dev->prev_siblings) to a new function. Good idea. Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | --kn225256pnovgin4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEBsvAIBsPu6mG7thcrX5LkNig010FAmJ7eAcACgkQrX5LkNig 010O0Qf8CEz2CHRSRsSKBUb5rg8XhWgg+Z/1qLnQ+fnIwut2NRazLzJxfxhU7+vo 5xIA+7lc4K/N7TQXGKDHtgCt/o4znlfnHYAaUWEJE/B0O0XLq/bxu/feg1///eZz rJqWtUCCDHDyIVENF8QNQ66ZKAjmqtxZio4xtrO2EmOihktlokp/2fmt0kd+Jh03 0vRz9mRJrKVj3Nb2n4MXerCSDuEK5Ne9Kco8UhGkuqY0+nlc/p7ZQv7aYCMxAj5g p/W7tVcDXNOqis6ywRUiI4YTTdXG26Hj9GcnSx1COmXzSdolYcmU0MOpQjsH/iYU y4EWtwp6ixPf389CUGsqTkrMXx63gQ== =UVby -----END PGP SIGNATURE----- --kn225256pnovgin4--