From patchwork Wed May 5 09:42:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 431461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E891BC4361B for ; Wed, 5 May 2021 09:42:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8B9C613ED for ; Wed, 5 May 2021 09:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232553AbhEEJnT (ORCPT ); Wed, 5 May 2021 05:43:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:48636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232413AbhEEJnQ (ORCPT ); Wed, 5 May 2021 05:43:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 440076141C; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=e6cg3vt5gdRSnzuWDjBWlr3jZ9qzDtzBe//Hw9aDZms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UTRFnfuFAjc8bTsLJzXYCs7bJJiLrJT4aQkq1wE9ELZ6bKZpIV6DU2/2WkfulFbcY cPj0VkZ3DAStETq7XrOAHya7zoBwOUAHf+uBYsaugIK2BUoPEEe3EIZiCXKxs/H3PY S1h4gng4dzYhzkIbwKC4FdNUn5hhX/jlvDXh1hQ2fZlbOI1zLz5ag+IGIh73Y2393A tHkNN1cFwcAc2/pPzizSb1l8tNLjGGzGmumw9eyhWgCrXvEmc52XZSyALnDEbkMIhF AOHskWLYGBMnAxEGxWrWYKHX9r+giFf3kl/zSllgbc8vInNM8g3KVFaa0jolGb1PLT nu9zA4ms+MRMA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwX-8H; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Hans Verkuil , Marek Szyprowski , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH 15/25] media: s5p: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:05 +0200 Message-Id: <57a141a2c538b253f1c9502a790c370007d2ed83.1620207353.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. While here, check if the PM runtime error was caught at s5p_cec_adap_enable(). Reviewed-by: Sylwester Nawrocki Acked-by: Marek Szyprowski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/cec/platform/s5p/s5p_cec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/cec/platform/s5p/s5p_cec.c b/drivers/media/cec/platform/s5p/s5p_cec.c index 3c7c4c3c798c..028a09a7531e 100644 --- a/drivers/media/cec/platform/s5p/s5p_cec.c +++ b/drivers/media/cec/platform/s5p/s5p_cec.c @@ -35,10 +35,13 @@ MODULE_PARM_DESC(debug, "debug level (0-2)"); static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable) { + int ret; struct s5p_cec_dev *cec = cec_get_drvdata(adap); if (enable) { - pm_runtime_get_sync(cec->dev); + ret = pm_runtime_resume_and_get(cec->dev); + if (ret < 0) + return ret; s5p_cec_reset(cec);