From nobody Sat May 10 06: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=1619518461; cv=none; d=zohomail.com; s=zohoarc; b=I+GtE26OIZ9e2vWJnfXbJeXBwRQsQb01JgvJEklLPdv2yY7jIW+1j5X26yhJj966sPq+9sS4VD0OdMomk3vy81gvB51xiq/lyZyRwdIUy28FA52luceJrRAQyBQU4dFMs+HnUG/t/X8VVfOltYWpILl6qL9nFL38CXKHlBF0ibE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619518461; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KgD/UET03mpXhrsM3R2k8AhQEpKAFT3bwKYvDYrD0nc=; b=WZrGkXDhNYC9KYzDPFoRVJl43zx5P5w8CP45Lqp2ssBD/UQ5qD7SHPEsYGH1e24N0kVFm7CXHymV59MvbEo00FiTUoFPH6RltDbfjqge5GZCQYnds4C/S7abRE/eMP/uwTq64ev6yIJyz8QBBq4AUkYuejn3gi6lMmvOd0yE/Ro= 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 1619518461867909.3694896723827; Tue, 27 Apr 2021 03:14:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235699AbhD0KPD (ORCPT ); Tue, 27 Apr 2021 06:15:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:34518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235246AbhD0KOe (ORCPT ); Tue, 27 Apr 2021 06:14:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC08F613C5; Tue, 27 Apr 2021 10:13:50 +0000 (UTC) Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKiy-000j54-K8; Tue, 27 Apr 2021 12:13:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619518430; bh=vSVgVx9oCI4BykR40BTa4+7tin+dlK2U4+Benc8+UkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHeOYgg17IAhtKf2kG3l5ENtWblBsn9K//nDeh3BI5v8/jaPW/tPDqgJPSy/cOetP 2ITKnyUMUnRbs0QofKRleV3Nm2SCKuVDgi8OJloO7UgTyOiCpHycLx2GqtFa2WA61q uVlgSsAxagmWMh9CL8UF33VbGYDzyLoCTGzxGr/BNxoHmoAkscZEu8TQhpOgABJwAn om3V9/pdHBgO67UyuHQMGuRz7xebZt1z4eK8LDoh/U/VRhpFDRkhJTCdzcdDQ4ilID FYHnhXzeR6DqiRz4R9Z0jH07yVCT/aPh9L3PG8IQ1Y07FuJ/YJ3psHKyQszyoymlGL 2C2wg2iZ+0lMQ== 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 v2 10/79] media: rcar_fdp1: fix pm_runtime_get_sync() usage count Date: Tue, 27 Apr 2021 12:12:37 +0200 Message-Id: <449ab92cf6920f1d66cb831e15d92aed7f5b7192.1619518193.git.mchehab+huawei@kernel.org> 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