Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9110265pxu; Mon, 28 Dec 2020 06:54:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPjg0kveejitxF8+RKjt8p4iq0Dp63F+BJmQn9pfoNIdOwDx06ww6vIMptWGwKWCA24pAt X-Received: by 2002:a17:906:a106:: with SMTP id t6mr2068088ejy.63.1609167290873; Mon, 28 Dec 2020 06:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167290; cv=none; d=google.com; s=arc-20160816; b=wJzoKchcMLIwlNOKpoM4Luq7F/Tva07LXKLHhLNgZLhQiWGnWhHRwolsOPXP0H0Qw5 H/vdDr/ixvm6L2Q4p7zjAvCC6gf8z6lr7bFz3c33vL1w6nhWaAB0mGuW5gypCqYCJ7E3 z1aw5KEcjnf00m6VgBI71SXVCq8cc1cY1dkEyx74PdESwWLWS4VAtJvnuQ/qgkjEnCR5 t36A974yFXX0eeGoWbCnLZbjDHn1fC6vJ83PnRCGWMqUPD5K4Y6GTTrmUi+1d8HnzQaz qBvfqX/yg1TzS1WRrM1wo9r3TNsS8p00WBqRChw9uNXdeO3m+X5cgUSqviIwVVvd9vNb XcUw== 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=3u1zcQg8Ni7xE8xu4QXPYKs8P1P2ixThg56R+Bsc28E=; b=J3AWKLSYqfDh8GE10mS2U5qDE6Kbd8QiK4ACZ5Lmc+T9MwTYkigvwUm1gVzGXNW+e4 JTpFbtc8b261mb12Gg76p1GFv/WXB1JVG07UqcTyMS5uzyWIfx9wZIApPsuDrdLOI19D 5+tbNu6WtBTYg7N4jRr+oIAmRrLVhHXVlkbxVO3bpIe1wHAJik64+7hAVHXlKsb6WLGg 6Xaq9HpVlpBWNYMi00ea/nTBCOdQCSGn5jWejvBL1OW2fSaZ3VAeEjghS4MIQb1OD8Jy GbliuJJVg+RGpK/5lEsbdsJ9GvvvngIwWbM4zwfR1UtT8Bmm5DGQCKy1iM3VJ/FfTqU7 83EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="B/SzPe2l"; 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 i24si19874132edg.295.2020.12.28.06.54.28; Mon, 28 Dec 2020 06:54:50 -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="B/SzPe2l"; 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 S2440474AbgL1OSk (ORCPT + 99 others); Mon, 28 Dec 2020 09:18:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:53606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391829AbgL1OSd (ORCPT ); Mon, 28 Dec 2020 09:18:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09BE1224D2; Mon, 28 Dec 2020 14:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165072; bh=1mpwmu2rQjWyRA2OQ+RoeB/jIrG4Sa2HWw1nGCzIb90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/SzPe2lmGUizKnSx5eNu5H8JPXUpZZlgtNFjf48wXN7gI96x22LmMmr7c2h+/cdE Boy+yJITArOn2pdbMlJtUjHzPgpQy03ivRHaI7SQx648BqymVYkr4ACdQuwIEfldBx lRs4HXw6PeHqVdqOOFSUZfjoakNC3Eirgm9NVHGc= 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 400/717] remoteproc: q6v5-mss: fix error handling in q6v5_pds_enable Date: Mon, 28 Dec 2020 13:46:38 +0100 Message-Id: <20201228125040.156084975@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 a24723050037303e4008b37f1f8dcc99c58901aa ] If the pm_runtime_get_sync failed in q6v5_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: 4760a896be88e ("remoteproc: q6v5-mss: Vote for rpmh power domains") Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201102143433.143996-1-zhangqilong3@huawei.com Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/remoteproc/qcom_q6v5_mss.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index eb3457a6c3b73..ba6f7551242de 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -349,8 +349,11 @@ static int q6v5_pds_enable(struct q6v5 *qproc, 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