From nobody Sat May 10 03:32:13 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=1619246765; cv=none; d=zohomail.com; s=zohoarc; b=D1olUZC9UhEDm587cZIIUxTMRdZBmjTlTqKlhyRSX9IuuhSbElnVxD0UmhDJMk64uhw31j655fNS/whlxIjxu+43MSe5527mcz+CGr+t6+5QhFnfySfYWksk1f7Rvhj2rXOOnHbVNpNJsbrOE+V7HDfQTNG6g2cA4vpaQ46yn6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619246765; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PMa6BNdwNv+ms8G8EeaHZJFCn7azEeneDlPD5njmX2I=; b=IZDb6ZE7iFVrmpYeUWcGmuW+fVm0Seqf0HoM/VEP0piNETzGwtXKuuhApib7dA7c3qlJs15k+jIP/qjiSqFW8I1vwti0k9s001Blogx5zhDxWys1Qa4EWKxALkNqywK4QY9cmxw/xzlmWXDF0u9GJiy2mvgCV1E8mNihnID40AQ= 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 1619246765055130.02462787014815; Fri, 23 Apr 2021 23:46:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237186AbhDXGqk (ORCPT ); Sat, 24 Apr 2021 02:46:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:35670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbhDXGqL (ORCPT ); Sat, 24 Apr 2021 02:46:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E67B861465; Sat, 24 Apr 2021 06:45:32 +0000 (UTC) Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1laC2l-004Je9-4K; Sat, 24 Apr 2021 08:45:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619246733; bh=SI6ASvXrwKssaCaDesHdO6M/J0SbTwTE6pmD5fN7U7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlvAJVdxYxdTiSmkV5piWLcfmZ7+vTiSrLw1ps3w8gNhBGD5Voq3MjTMnVDUljV/G dqDVisj6scq5gMu+6xGvmbnT+uHd0+V0oHRw/x3n1hrxGMrs22N+hCF5VxDjhI5hA/ VM+kWm1D8lHh+0cS65zHwwvc6Sn8h3B0ClzC1YrFVU8RRL5JGIBtonqgT999a7nV86 gfeILM9cSmDu+tS3A3i98cpFpmC0y5v/nuE1FOyhpjQt5GJCK0iKX7mOs1UFhHSyVr WwAIFr5ohLarof++aQWg8MVcuLLNXZkabz88Fl19DAMHJvXcfsiZ/OGzKnFhcdKaaz 3ua0iRxgMtkzA== From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , "Gustavo A. R. Silva" , Geert Uytterhoeven , Hans Verkuil , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 09/78] media: sh_vou: fix pm_runtime_get_sync() usage count Date: Sat, 24 Apr 2021 08:44:19 +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. While here, check if the PM runtime was caught at open time. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sh_vou.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vo= u.c index 4ac48441f22c..ca4310e26c49 100644 --- a/drivers/media/platform/sh_vou.c +++ b/drivers/media/platform/sh_vou.c @@ -1133,7 +1133,11 @@ static int sh_vou_open(struct file *file) if (v4l2_fh_is_singular_file(file) && vou_dev->status =3D=3D SH_VOU_INITIALISING) { /* First open */ - pm_runtime_get_sync(vou_dev->v4l2_dev.dev); + err =3D pm_runtime_resume_and_get(vou_dev->v4l2_dev.dev); + if (err < 0) { + v4l2_fh_release(file); + goto done_open; + } err =3D sh_vou_hw_init(vou_dev); if (err < 0) { pm_runtime_put(vou_dev->v4l2_dev.dev); --=20 2.30.2