From patchwork Wed Jun 30 22:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 468741 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp786440jao; Wed, 30 Jun 2021 16:00:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHmZoizXRLvKh6oHOniW4fgz4kmXesr/NeAz0pSGd+419AIjWZSfZnzrY+FpWEf0yY9AWU X-Received: by 2002:a17:907:3d8e:: with SMTP id he14mr37580302ejc.374.1625094003386; Wed, 30 Jun 2021 16:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625094003; cv=none; d=google.com; s=arc-20160816; b=Eado6NTxA3pIYD+BHyGKZTeVlsPqVVMPXuy1ldhb/k8OMZOnFJVkENEsanr53FG0hB y12IEW+5HnXeh5xnMkVveLzHATiAXZ5ubES2FaiRg5rgWZVEDNfn7TUxpVr1xVHkjy+r 5KO5cBeGgvAJ6xX9fj4OF6AGm6Vscrksoka+BEUA/k2AV37YvyMmZ2vM8Kpj+cuJjP13 S7OKKVrP+YLFuywqPaXy/E7iiWiCy4I0EHM+AIBxUQiFU3C4qnyqJ1hjovHuq/Ixxgj5 fPdrX60C+r0US0svmZgDPCuxt4tRcxWm6E3tc9/mEv8w0mBjR8wJmW1BDdabnST8WL9H 7njQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lPH2sT2kWyJ067X+i8qH7IKutZ8IRpZkl3/aR7wJJdc=; b=PsaLzOXS3/mRmA1Th5vTwj+bzPHJ9fPkF8LQ6fBi0b9smz0Nm5jigcqn6xyqMuPAtd Im+b8+4GYmYLWOh4/0zd8yFZ2KaRXO0VXrVoxDEGVL1PjEbAEswdIPHwJNkIPcXoHgwF XS2MQcOnkk1CR9RWSmvaLAbgUK7dbTRjvvc8jJe8uo00fIhtonjNjBDd0ndh0NPeJK6/ OjS6g6ga2kY7Tzx7SSsf6q5nylwY94CwnCw9F67psvT7Ei5+xDAQ012xep8sEyJvOi2L Aro6yt5K+/jJRSss3mNAXzD4QgpSWowpTIqD+8Ulnv5MX+jckTcexLDbRdhtubtLIFeS G8sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=emPuOvHn; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si291785edp.69.2021.06.30.16.00.02; Wed, 30 Jun 2021 16:00:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=emPuOvHn; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233650AbhF3XCb (ORCPT + 17 others); Wed, 30 Jun 2021 19:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232559AbhF3XCa (ORCPT ); Wed, 30 Jun 2021 19:02:30 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9658BC0617AE for ; Wed, 30 Jun 2021 16:00:00 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id k10so8041769lfv.13 for ; Wed, 30 Jun 2021 16:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lPH2sT2kWyJ067X+i8qH7IKutZ8IRpZkl3/aR7wJJdc=; b=emPuOvHntGovS+gGBec8JXp3MFU3Fqi64Tat79stxSN9pfzFwJZqYAYafN42s302Gf xiZXXQGLinDFP0+CV0NnGCypjPPOe4tQS2ztvaSxA3LiR0lunHuAmnfaI8VmfyWQVddq 3ibrZdLam7hT/lY70r8jnF0ZZ3BNCKjWrKhtfEu6kK5m1ZrZ88gAIkEQd7ly5XXMHNnN UzF9U/xEBi1QXuoEPkymcsgedTOBRLJLcJZN/A1CpTyYjrsb8M1OF812ozi/T0QvvHS2 wp5YZaBtBjl+XasmpQGHlG2M7K9BLyeRtBaqTQQgyC2OOvU+MUy9Y/XEvI7cvR5u4HRA 8Nqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lPH2sT2kWyJ067X+i8qH7IKutZ8IRpZkl3/aR7wJJdc=; b=QeYtR+QiafhkZiewu6QRrNQlTR1Bi4Q7EldsuRP/t01X7CwMxw44p8FWzPYKr+gWQr vBnMXNdCnkZI8GzkhRNJpdAI2CG0+atW3E9FqEMCRfLWqi5VXUwG871qSuY5rWkotrix OGNy0tscSo+Kk1SRgcO2jqGrwQ2zBmp164z1Iz/XGYyPCvf3wN4VkK/rjvquSzyaQbPu MECjoIC+C4n7Iu1nJFS6jqYZ4lvIewvz0S5Y2CODmNFKc+TwBJ331oA//mdw45tPdFSo htL2EuRjFYACRxy1eUJmDjyyJqT9c4JA1/3FxGzD764U+M19gscGoBytHhRDrvoagW2Q T/vg== X-Gm-Message-State: AOAM531pePJphIrVy7v2dWTFpm7tdGqAnb0QBqxSdsfr8R/Xpf71wiWV mWIpaHHMwcRM4+0e5jRFYxB4dSD+3X7BCw== X-Received: by 2002:a19:f11a:: with SMTP id p26mr888825lfh.113.1625093998965; Wed, 30 Jun 2021 15:59:58 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id e17sm2324444ljn.125.2021.06.30.15.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 15:59:58 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Stephen Boyd , Michael Turquette , Taniya Das Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v2 1/2] clk: qcom: fix error_path in gdsc_register Date: Thu, 1 Jul 2021 01:59:51 +0300 Message-Id: <20210630225952.3337630-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210630225952.3337630-1-dmitry.baryshkov@linaro.org> References: <20210630225952.3337630-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Properly handle and cleanup errors in gdsc_register() instead of just returning an error and leaving some of resources registered/hanging in the system. Fixes: c2c7f0a47493 ("clk: qcom: gdsc: Add support for hierarchical power domains") Fixes: 45dd0e55317c ("clk: qcom: Add support for GDSCs") Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/gdsc.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 51ed640e527b..241186d9d08c 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -429,7 +429,7 @@ int gdsc_register(struct gdsc_desc *desc, scs[i]->rcdev = rcdev; ret = gdsc_init(scs[i]); if (ret) - return ret; + goto err_init; data->domains[i] = &scs[i]->pd; } @@ -437,11 +437,35 @@ int gdsc_register(struct gdsc_desc *desc, for (i = 0; i < num; i++) { if (!scs[i]) continue; - if (scs[i]->parent) - pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); + if (scs[i]->parent) { + ret = pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); + if (ret) + goto err_subdomain; + } } - return of_genpd_add_provider_onecell(dev->of_node, data); + ret = of_genpd_add_provider_onecell(dev->of_node, data); + if (!ret) + return 0; + +err_subdomain: + i--; + for (; i >= 0; i--) { + if (!scs[i] || !scs[i]->parent) + continue; + pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); + } + i = num; + +err_init: + i--; + for (; i >= 0; i--) { + if (!scs[i]) + continue; + pm_genpd_remove(&scs[i]->pd); + } + + return ret; } void gdsc_unregister(struct gdsc_desc *desc)