From nobody Sat May 10 03:09:18 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1619246781; cv=none; d=zohomail.com; s=zohoarc; b=E2zagcGC0nIcGxhVw98iZQWVgHd4gTDT+dF0KTsIUoxcFZvlpsGfFHHRAeectTeUsvHCaRv7Qqg+tDwI4zhfYqawNaMHuSpwb07G2cwsRuRND/8Un9QSzxjl7FaLH55EVXmUfdAe2qa9Qrwe0y6HKb8SaHHflsSkAI+Vq6fBgMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619246781; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2qgZlRZDkMCjsJgpU5zQRwCOYFVsCp8ADYLisNHpm90=; b=ijX512CAPtV7gYGdUarCwho2dpCLCELZ6FDBILJ2y4cDn5Vj5U6ELHJczb2CB2nP0nt9qSYh6hXxSaJztIOClD52zk2JSy91791pHbtjEtxKeAXOwwK7F5WdGTh/bGXsJrZvgKqQnlA9gxZLyMfJYPCWaIsNGhBUjKBW9jlgM5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1619246781120970.8338076252556; Fri, 23 Apr 2021 23:46:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236977AbhDXGqz (ORCPT ); Sat, 24 Apr 2021 02:46:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:35724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbhDXGqL (ORCPT ); Sat, 24 Apr 2021 02:46:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 00F5561490; Sat, 24 Apr 2021 06:45:32 +0000 (UTC) Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1laC2k-004Jdu-Vn; Sat, 24 Apr 2021 08:45:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619246733; bh=vlWzPcglj3c5YNM8fjCOIG3b1giv6Ug3RyqxVuPOXCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o3EHnDj8lhhvnbL6MRbpHKQ/z5hcFwYB1uy5+C27DD6o3NjrCIAnM8ePevlYORY1E vDCdRSv/aGJRGra5RwV34014Euwi8obXklrpKcV/B0nbgOrDzQJDukjCPF2dKYXtJx aRb17bfiiUsJsB3ed19jypufTmKuczryK+6CX/Z5eAGEblROp19TX6LRptFxkMdhxw SXgUcfLSF6tHZWkCs0N/w9Y40O6Bd1CjS+nfLgWiI+S6eJ7+oXwzkBBpXUPXzebuxA yF/oLgT53PzqbltJZ5DQX8XNegGPKaC7G+ohOZmkSSpePo0goIgxJUgHV1Io+vzjb2 oDJCxo5PtSS2w== From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Kieran Bingham , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH 04/78] media: rcar_fdp1: fix pm_runtime_get_sync() usage count Date: Sat, 24 Apr 2021 08:44:14 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 wi= th usage counter") in order to properly decrement the usage counter and avoid memory leaks. Also, right now, the driver is ignoring any troubles when trying to do PM resume. So, add the proper error handling for the code. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/rcar_fdp1.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rc= ar_fdp1.c index 01c1fbb97bf6..c32d237af618 100644 --- a/drivers/media/platform/rcar_fdp1.c +++ b/drivers/media/platform/rcar_fdp1.c @@ -2140,7 +2140,13 @@ static int fdp1_open(struct file *file) } =20 /* Perform any power management required */ - pm_runtime_get_sync(fdp1->dev); + ret =3D pm_runtime_resume_and_get(fdp1->dev); + if (ret < 0) { + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); + v4l2_ctrl_handler_free(&ctx->hdl); + kfree(ctx); + goto done; + } =20 v4l2_fh_add(&ctx->fh); =20 @@ -2351,7 +2357,9 @@ static int fdp1_probe(struct platform_device *pdev) =20 /* Power up the cells to read HW */ pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(fdp1->dev); + ret =3D pm_runtime_resume_and_get(fdp1->dev); + if (ret < 0) + return ret; =20 hw_version =3D fdp1_read(fdp1, FD1_IP_INTDATA); switch (hw_version) { --=20 2.30.2