Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9110354pxu; Mon, 28 Dec 2020 06:54:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJya5gmbO8JB9/mXxPOM4FT5I9E0zI9Iz6HFJY/FIdFC77R5teVPskkkfjiiY6y+P9mxImxs X-Received: by 2002:a05:6402:3074:: with SMTP id bs20mr42233648edb.365.1609167298994; Mon, 28 Dec 2020 06:54:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167298; cv=none; d=google.com; s=arc-20160816; b=0SOp0ezBZhzt+C6yvcvY6dZxwQoHc0tv592TkqENEHmzaxnvLW4U8v6wsMtukCqtfm S5Sbwd+MCKeFLUtlUWJw1EYI/NR1b1nmj2ulKp55I+7q3Hsj4o5GMVBJqdauVnVtxJaQ pxL+vocXusxpZM5sw5ha29YYRdSGcGqmA9+d2a3vMu+wG9aU+xtO7Dqe1IJZoC9ObCab UMSP5j48syTV/+6z/IPzhkRVcT6aaZBDwnrKpj6q9PipNNIBkI8Qbm2QQ7KIDbqO5UqT cOoJ3M1lsC7lVJdOZH//mJfj7wxAkRKylJWhhTjiqdH2f/6EMBZdMbrD66u9yxzwwpCq Jr8w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6R6bspq/6ioZJfPJGFsNq/v+43UWyMxqBSOlcVdNptk=; b=cqDAz2BKpHRjvYZdBBQSpwA3wHCj+gL0RN3NFjlTAkQgg3vi9VM1braKHd0saHM662 iDIJuw1gpjD3x5POlnskckpVB943LFm2WxDxrcWMUR56uJaahr0/PVnQyh1ReDQ8F+sZ a1gGq4MI3RtNlqK8S405TfaZsL2FXAkcfqprh2catyC5eeNO8/RNcLua5rzbVLZ89Ox9 7mJb9elTk9cPM4WrScxd7quEpTyL+2PVvKq9YwBOBLEEcjzN9qp8hG1rWhOduwMtGnUN 6bjJUf5uuvp1kl6f7WVtwfjJwp5Koi+KKYG1AFD2oXzi2Xqgg6KEIP9atY9e6NaZH1tr DO7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kgQd24gM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kt26si15874242ejb.443.2020.12.28.06.54.36; Mon, 28 Dec 2020 06:54:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=kgQd24gM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502735AbgL1Ow2 (ORCPT + 99 others); Mon, 28 Dec 2020 09:52:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:53838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2501983AbgL1OSj (ORCPT ); Mon, 28 Dec 2020 09:18:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB25D208B6; Mon, 28 Dec 2020 14:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165078; bh=kx/tp4SqoPRPduAGYsbIFkZwQcXb64ozLaWoYI2fSwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kgQd24gMQjuxSJRAgHEGsSg3IyMp/qB7kdkJfD6jGY/KGCYToHiGZRLBczLtfxrD3 nSTSaxWcOTlBdk6Xi5OYIeGeYaJ0modXzHLWtButPgdxI52f7HmOSgMSqqdgglVs0f ZTq1MAYY1SlxOeXZ8tQqkD8FZSVCU+wnAEEA6tI8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.10 402/717] remoteproc: qcom: pas: fix error handling in adsp_pds_enable Date: Mon, 28 Dec 2020 13:46:40 +0100 Message-Id: <20201228125040.251411008@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qilong [ Upstream commit c0a6e5ee1ecfe4c3a5799cfd30820748eff5dfab ] If the pm_runtime_get_sync failed in adsp_pds_enable when loop (i), The unroll_pd_votes will start from (i - 1), and it will resulted in following problems: 1) pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to pm_runtime_put_noidle will result in reference leak. 2) Have not reset pds[i] performance state. Then we fix it. Fixes: 17ee2fb4e8567 ("remoteproc: qcom: pas: Vote for active/proxy power domains") Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201102143554.144707-1-zhangqilong3@huawei.com Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/remoteproc/qcom_q6v5_pas.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index 3837f23995e05..0678b417707ef 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -90,8 +90,11 @@ static int adsp_pds_enable(struct qcom_adsp *adsp, struct device **pds, for (i = 0; i < pd_count; i++) { dev_pm_genpd_set_performance_state(pds[i], INT_MAX); ret = pm_runtime_get_sync(pds[i]); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(pds[i]); + dev_pm_genpd_set_performance_state(pds[i], 0); goto unroll_pd_votes; + } } return 0; -- 2.27.0