From patchwork Sun Sep 3 21:41:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 720204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 571B8C88CB2 for ; Sun, 3 Sep 2023 21:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349116AbjICVmS (ORCPT ); Sun, 3 Sep 2023 17:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349137AbjICVmE (ORCPT ); Sun, 3 Sep 2023 17:42:04 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53CA8126 for ; Sun, 3 Sep 2023 14:42:00 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4ff8f2630e3so1429712e87.1 for ; Sun, 03 Sep 2023 14:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693777318; x=1694382118; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+Fl8gZia3d8uGRSMrCOuo+xZGwzdrHyhk9K+cL7FZyc=; b=WTpHh5M9kY04howTyEB8GN/GLm/GKC1zwGchyEUCNR7tihUUiXkVO83OSwPoA89lbE WlpYyvcDBWvWB6vsQlANHsA8Enpx+lSFlswXgAT9BAOY9oeMeDOn6z+NMZM23+S4XkPU YOOPgUg2ZMC8dl6oEVqE0lqbXCNtD8D6KPmpjYDJNyGOrXayYg9o8hJgD5xLkS64qCf8 sEIkZNXYcS9Irzhb/k/Sv+AYigXMFbdLBbzIP5ZT4y3x8KUqxW6SFhgA9eDLK2vJBfw/ C7taRXEotxCJt5eBv/IYqro7O6fODj1/nNKu161429SNm0BkFuViFeKxtKKbEdhEBCrY uAuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693777318; x=1694382118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+Fl8gZia3d8uGRSMrCOuo+xZGwzdrHyhk9K+cL7FZyc=; b=ECb/fYo+8g4ScoTNSNpiaxKu1wLqz4BKuLoHKsVXJKYa3PLJKn0YPES7cvSaNU/Tgj +EaXb7Y32FGdzy6zphWiSHE1331VnB4C/57MzZyZ2fW7yfREVpUfjrrTtSigvPD32DFH u3WucOE/KDv3ucdRqfPjCcMja5Sz1zEcnX5O9jHU5lLhqjZJyZeVx950yCrktfU2yA46 HxEzsjLhkV6bzPq6+nV96mws+kju+NEw7bahl4KNLmOSNK8fkWi5Gi7Fy71tbRluJvlu UYuLFstWTyCUT/gqDvtsfX70Uw0Q2/vB+5uU5nChf4GqV4O/BxKESFOGU7Kvru1lEg63 EUeg== X-Gm-Message-State: AOJu0YzFSZEH93/W1W13zSpRdZ2/hg2+tFa9G9KPoKD3idQEhpNAxmCP 3OuIv4Jrrkq2rUgKypWLIg8s8g== X-Google-Smtp-Source: AGHT+IFB7g1NLcGbFTo55gFtReAERXtRLC3wSNcCmU3/Hx6wGeI5ha18iUymtWlOuu8WNDnb4g6j1g== X-Received: by 2002:a05:6512:446:b0:500:9bbf:da17 with SMTP id y6-20020a056512044600b005009bbfda17mr4134008lfk.51.1693777318743; Sun, 03 Sep 2023 14:41:58 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id x17-20020ac25dd1000000b004f8555f7aa1sm1422506lfq.52.2023.09.03.14.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Sep 2023 14:41:58 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , "Bryan O'Donoghue" , Guenter Roeck , Heikki Krogerus , Janne Grunau , Simon Ser , Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [RFC PATCH v1 10/12] usb: typec: qcom: implement proper error path in probe() Date: Mon, 4 Sep 2023 00:41:48 +0300 Message-Id: <20230903214150.2877023-11-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230903214150.2877023-1-dmitry.baryshkov@linaro.org> References: <20230903214150.2877023-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Implement proper error path in the qcom_pmic_typec_probe(). This makes sure that we properly disable hardware blocks and do not leak memory. Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver") Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c index 581199d37b49..ceda594a8d56 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c @@ -258,15 +258,22 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) ret = qcom_pmic_typec_port_start(tcpm->pmic_typec_port, tcpm->tcpm_port); if (ret) - goto fwnode_remove; + goto tcpm_unregister_port; ret = qcom_pmic_typec_pdphy_start(tcpm->pmic_typec_pdphy, tcpm->tcpm_port); if (ret) - goto fwnode_remove; + goto typec_stop; return 0; + +typec_stop: + qcom_pmic_typec_port_stop(tcpm->pmic_typec_port); + +tcpm_unregister_port: + tcpm_unregister_port(tcpm->tcpm_port); + fwnode_remove: fwnode_remove_software_node(tcpm->tcpc.fwnode);