Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4473026rwb; Mon, 31 Jul 2023 07:25:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlGt6sLBiJ/GrCYB/UTPG23ZRFgK04DfKtZc7yM9oOUbh0QpbMl83crVOjXo0APgBHqm/zF3 X-Received: by 2002:a05:6870:ecaa:b0:1bb:5e7e:dd6 with SMTP id eo42-20020a056870ecaa00b001bb5e7e0dd6mr12051427oab.40.1690813530794; Mon, 31 Jul 2023 07:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690813530; cv=none; d=google.com; s=arc-20160816; b=vnvdQN10yXrHOlo7yajSaN/uM4YrN2zsViDYQ/vYYaZ8i9elsRd4AfxFUf1ENeq0Je /q18nNTd68LU8m86y6Ehg0+NfZ85WuL2Qsk/a3C9MjFk7Rz0bcmSEaPdvxOAo9SQXCtr /6+BDjHwDBPGDPSeSISeNOrazMNF7FBRh2zKrrZyIruBh/GpZ94YtVcaoXF73yQ68PT/ iZEq4x7RfDrRoyTiC8QgUrhswqeQsnCwmvqoav4xhy6Jbf0KUrF5vwpzDElI/Y4uWjrs tpTezd3c64pnuhYU1SBSj0H2H8wKGGY1DUrFwiqPI8gUffgHNHej3INnbtW1OrwEh2Hn w4eQ== 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:dkim-signature; bh=dwz6jn+c63RYNEcSrQbM+DjFu+CGhuvuyCaOIgwwJUY=; fh=vpf9xI0SEgMIKZl07QXJ5enfNTDHivF0FNpILp0wSsA=; b=cra2Cm3QJesiJ0Ev5ChT0BBjrIlRP5atkf84/+1mnIeYycHesr0Qnq+K3z6r5eIbBZ sbfCh/vJwcfdSjjEYGJIMnsVoIE2kjHIHf7fRaFY5Q3N4EyiVZaxkEt5Atjtce9CJMFH seMoli2v2QeAb3wkg1rbzr2lyh0my3yPVHlc5IMp3u6sUwpwaGFF16bvnVSQuWxg9w8e 4la5KZV8JKsFDq+XAnpwArsNkEsNjHDFIGGteL9niEXaGxAG7zrUszmj3tZXPvnbul8h DL7cTaiRIPG6C/ohYr1JxqLfo2iVFaHC5cWKVwcpG937w8Wni1VvnCPIugtZchMUdsIl /+Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LDJazHXw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a63de0a000000b00564514df64bsi1346163pgg.897.2023.07.31.07.25.17; Mon, 31 Jul 2023 07:25:30 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=LDJazHXw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232871AbjGaNQd (ORCPT + 99 others); Mon, 31 Jul 2023 09:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbjGaNQ3 (ORCPT ); Mon, 31 Jul 2023 09:16:29 -0400 Received: from mgamail.intel.com (unknown [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69719E75; Mon, 31 Jul 2023 06:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690809388; x=1722345388; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=i2O+ffUC3QkRd8lfDmc9uuiKSy0hOGcWGfhz9xoZCAQ=; b=LDJazHXwfy48TJMetdVS6zx+dom4vEeJ8sYkmrrPKS4BkXKTaYmA7NXI U5CBf961taMnn8Yl3y66DWQuZsBqksKW+7yoFzlzkVVYoQvqSt3o6pWAd RGDpMbGwm5wQEIz36ewLJCeIwczsmp4a5GW08ZVAjD92qvQXOCDm3eDip UFQKY5u8yh9UVaPrV2i+N0Vm9UQDgOlBtfTiip1Lg8P3Kcv19g6WwayJJ L94CzzQk/nwv0MpbQvi9nksFOdcACYcyn8udc52/O9BrzMAHPnuEdEazb 7/51rNhPkLWCN4NldIF+JvQK8UqmoxTFRsxVsyGPCbguXrbvoBI+CVH2e w==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366497449" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="366497449" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 06:16:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="871671819" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 31 Jul 2023 06:16:27 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 31 Jul 2023 16:16:24 +0300 Date: Mon, 31 Jul 2023 16:16:24 +0300 From: Heikki Krogerus To: Christophe JAILLET Cc: Greg Kroah-Hartman , Dmitry Baryshkov , Neil Armstrong , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH] usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe() Message-ID: References: <9118954765821ea9f1179883602b4eca63e91749.1689716381.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9118954765821ea9f1179883602b4eca63e91749.1689716381.git.christophe.jaillet@wanadoo.fr> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Tue, Jul 18, 2023 at 11:40:05PM +0200, Christophe JAILLET wrote: > In case of error in the nb7vpq904m_probe() probe function, some resources > need to be freed, as already done in the remove function. > > Add the missing error handling path and adjust code accordingly. > > Fixes: 88d8f3ac9c67 ("usb: typec: add support for the nb7vpq904m Type-C Linear Redriver") > Signed-off-by: Christophe JAILLET Acked-by: Heikki Krogerus > --- > This changes the order with some devm_ allocated resources. I hope this is > fine. At least it is consistent with the remove function. > --- > drivers/usb/typec/mux/nb7vpq904m.c | 25 ++++++++++++++++++------- > 1 file changed, 18 insertions(+), 7 deletions(-) > > diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c > index 80e580d50129..4d1122d95013 100644 > --- a/drivers/usb/typec/mux/nb7vpq904m.c > +++ b/drivers/usb/typec/mux/nb7vpq904m.c > @@ -463,16 +463,18 @@ static int nb7vpq904m_probe(struct i2c_client *client) > > ret = nb7vpq904m_register_bridge(nb7); > if (ret) > - return ret; > + goto err_disable_gpio; > > sw_desc.drvdata = nb7; > sw_desc.fwnode = dev->fwnode; > sw_desc.set = nb7vpq904m_sw_set; > > nb7->sw = typec_switch_register(dev, &sw_desc); > - if (IS_ERR(nb7->sw)) > - return dev_err_probe(dev, PTR_ERR(nb7->sw), > - "Error registering typec switch\n"); > + if (IS_ERR(nb7->sw)) { > + ret = dev_err_probe(dev, PTR_ERR(nb7->sw), > + "Error registering typec switch\n"); > + goto err_disable_gpio; > + } > > retimer_desc.drvdata = nb7; > retimer_desc.fwnode = dev->fwnode; > @@ -480,12 +482,21 @@ static int nb7vpq904m_probe(struct i2c_client *client) > > nb7->retimer = typec_retimer_register(dev, &retimer_desc); > if (IS_ERR(nb7->retimer)) { > - typec_switch_unregister(nb7->sw); > - return dev_err_probe(dev, PTR_ERR(nb7->retimer), > - "Error registering typec retimer\n"); > + ret = dev_err_probe(dev, PTR_ERR(nb7->retimer), > + "Error registering typec retimer\n"); > + goto err_switch_unregister; > } > > return 0; > + > +err_switch_unregister: > + typec_switch_unregister(nb7->sw); > + > +err_disable_gpio: > + gpiod_set_value(nb7->enable_gpio, 0); > + regulator_disable(nb7->vcc_supply); > + > + return ret; > } > > static void nb7vpq904m_remove(struct i2c_client *client) > -- > 2.34.1 -- heikki