Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp762765ybb; Fri, 3 Apr 2020 11:20:33 -0700 (PDT) X-Google-Smtp-Source: APiQypJdOfO1gtkIvir/pGRhV2Buz3NOQkZnFygehWAb8WZARJJgtrbSZ0TENXVB1fyMMAGWnFhg X-Received: by 2002:a05:6808:648:: with SMTP id z8mr4228123oih.72.1585938032869; Fri, 03 Apr 2020 11:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585938032; cv=none; d=google.com; s=arc-20160816; b=zcJ8Yt/GjZIycbn25d+28C1pL+Y1wMFulnPmJjfj2jzmJdv3j4CrPhP6SOBMq2SFqM CRf/ZK/zB9hHSgIHkGoYmoDEpXLGn0UmQMTeH2l37HSWuDvcD441OMlfT4iBKTA5dir3 ksgzMkqsCJo/QukR+4IT8HllfTjE2+qr61QlZT5nl95uCoYu2ih5NPx7pXn3g0oSzJIL N+MFmOVtuRMaBgU8VPfy9Rv0zXiFgdiMw1SLDXdeMYmCk1wqpmvWqZYIRUGbmTfXoTq/ DT7xGRJa4DOTTUEn8Pov4vDc5+c3OI6Yj+hCsgtNXlKK5455nKxbGAtRaM1xiRQ522Pd NpDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9cI4scVoKJKw1b/HO6QaDyp3LKbjdrfchQuuiHLWjWc=; b=r0xg8V33V0eGZ30TSjeVWz0Od+FYObGyGg178iZ/cE0jqSe8FyQsxXm/mu6IiOQtE9 45La8hwgcypzZ/IcRK3cfmaDw6iWJSHTSUtQ1i0m734pu8n6J+wfLzr48kiI7ucZfLlb HSIuaBgUxTXW6Kfb42QCTun5gG6qMtA+mMqAPXif6oOO+wa+X6F5HJuMz0gEbqTVzLe6 Y4IiDEJIwb58AYH4ULn61J+J6dNhaMF0CIcJH32ovdZ17wFjAb68zAU8mQM3kwtjDUjU J7Gt5FTRTm1V1taY2c0K4r4NafGNQI0bG1bnQdfiB+ODIob9Ato2fhR1rj8rkA44NN8i 19CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rLMMh5/u"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id r6si4222757otc.12.2020.04.03.11.20.19; Fri, 03 Apr 2020 11:20:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rLMMh5/u"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S2404273AbgDCRuR (ORCPT + 99 others); Fri, 3 Apr 2020 13:50:17 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:44314 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404221AbgDCRuQ (ORCPT ); Fri, 3 Apr 2020 13:50:16 -0400 Received: by mail-qk1-f194.google.com with SMTP id j4so8857879qkc.11 for ; Fri, 03 Apr 2020 10:50:15 -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=9cI4scVoKJKw1b/HO6QaDyp3LKbjdrfchQuuiHLWjWc=; b=rLMMh5/uZTRR5enw62HL/VSaxyamFjN4+UGzBnS8klJ3U4s3RFmAAyCL4wGrLkwMpq 52GPlvDoYnNkCsbId8slVjxMWH/y2XSa5iO/SWWdtbE1VTehRN2UhVzyxcHcweV6tfe7 2trbZ0MYKH6SqYhemT4a9SRZPY9m9xaWs9UVfR90W/8FxBdn/kwXkx4vcMf+OVFV+R+Y MIWBr6DA7YvHjhy/GpAYvvRn0uvyleJk10fTq1YLU2+g57CrXsT8C8V7KL4NSMr6eVf0 KAsUBdiCPDu823eqBD98pLdlOHOXeUqHH9DDsP3fbQrEz/lZdyEyaP9WOpvKfIHaww3B Yfnw== 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=9cI4scVoKJKw1b/HO6QaDyp3LKbjdrfchQuuiHLWjWc=; b=lrlP9gHcaMVS8QcFeLYojUIfdOvtYcEiMO4sCLPUoBsZ0PQ26tUU3Hwv0QWCaWAKOR XX0PuAMFB+z7aZMzp5O6MLmivBSaTCoKzr9y+hs1NloqTnCbSRnvxY9UwkYB4oarpXo0 AHv0eOd17BXkbeKCjrgggI2SwOFVJ8ebKVeurkTrBv49Z5LJcG/IbEciOrMXLHA5wC1B bYBI35/HPgQlnFXiiL3saAoBWQdYDbRTwIZW/xeuhDX67JtMn77Rm1/HksLA+FbUFoVE J86jFQd8t49qFJ2+6/C5lB24mglGLIKp4crLkyEwMLHr9RgqfpYWfhg1HIYJqXU815US nlRg== X-Gm-Message-State: AGi0Pubjfxm4YNG/DYkgUZ+ssclh+rmzzmb6HLvmvDLurYg5pCagIRaB 8PK6PTGyFfDZ+yr+oXvyEhgww9i/dPIvhw== X-Received: by 2002:ae9:ee01:: with SMTP id i1mr10181110qkg.498.1585936215146; Fri, 03 Apr 2020 10:50:15 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id 77sm6821225qkh.26.2020.04.03.10.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 10:50:14 -0700 (PDT) From: Alex Elder To: Bjorn Andersson , Ohad Ben-Cohen , Andy Gross Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] remoteproc: qcom_q6v5_mss: fix q6v5_probe() error paths Date: Fri, 3 Apr 2020 12:50:05 -0500 Message-Id: <20200403175005.17130-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200403175005.17130-1-elder@linaro.org> References: <20200403175005.17130-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an error occurs in q6v5_probe() after the proxy power domains are attached, but before qcom_add_ipa_notify_subdev() is called, qcom_remove_ipa_notify_subdev() is called in the error path, which is a bug. Fix this by having that call be reached through a different label. Additionally, if qcom_add_sysmon_subdev() returns an error, the subdevs that had already been added will not be properly removed. Fix this by having the added subdevs (including the IPA notify one) be removed in this case. Finally, arrange for the sysmon subdev to be removed before the rest in the event rproc_add() returns an error. Have cleanup activity done in q6v5_remove() be done in the reverse order they are set up in q6v5_probe() (the same order they're done in the q6v5_probe() error path). Use a local variable for the remoteproc pointer, which is used repeatedly. Remove errant semicolons at the end of two function blocks. Signed-off-by: Alex Elder --- drivers/remoteproc/qcom_q6v5_mss.c | 31 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 60cdf699ea80..5475d4f808a8 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -367,7 +367,7 @@ static int q6v5_pds_enable(struct q6v5 *qproc, struct device **pds, } return ret; -}; +} static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds, size_t pd_count) @@ -1527,7 +1527,7 @@ static int q6v5_pds_attach(struct device *dev, struct device **devs, dev_pm_domain_detach(devs[i], false); return ret; -}; +} static void q6v5_pds_detach(struct q6v5 *qproc, struct device **pds, size_t pd_count) @@ -1766,17 +1766,23 @@ static int q6v5_probe(struct platform_device *pdev) qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12); if (IS_ERR(qproc->sysmon)) { ret = PTR_ERR(qproc->sysmon); - goto detach_proxy_pds; + goto remove_subdevs; } ret = rproc_add(rproc); if (ret) - goto detach_proxy_pds; + goto remove_sysmon_subdev; return 0; +remove_sysmon_subdev: + qcom_remove_sysmon_subdev(qproc->sysmon); +remove_subdevs: + qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev); + qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev); + qcom_remove_smd_subdev(rproc, &qproc->smd_subdev); + qcom_remove_glink_subdev(rproc, &qproc->glink_subdev); detach_proxy_pds: - qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev); q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); detach_active_pds: q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); @@ -1789,19 +1795,20 @@ static int q6v5_probe(struct platform_device *pdev) static int q6v5_remove(struct platform_device *pdev) { struct q6v5 *qproc = platform_get_drvdata(pdev); + struct rproc *rproc = qproc->rproc; - rproc_del(qproc->rproc); + rproc_del(rproc); qcom_remove_sysmon_subdev(qproc->sysmon); - qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev); - qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev); - qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev); - qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev); + qcom_remove_ipa_notify_subdev(rproc, &qproc->ipa_notify_subdev); + qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev); + qcom_remove_smd_subdev(rproc, &qproc->smd_subdev); + qcom_remove_glink_subdev(rproc, &qproc->glink_subdev); - q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); + q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); - rproc_free(qproc->rproc); + rproc_free(rproc); return 0; } -- 2.20.1