From nobody Sat May 10 06:26:20 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=1619518457; cv=none; d=zohomail.com; s=zohoarc; b=T2U8aK/pxIjcSzDlHTDtVFV221Ex6jGYHisOBrLZo2YnOH9snWJwZO2rox7w5c9m+4+ZKx/xAbAy/E+FHC8y7mz4AqvaHyiv3Cxyrj6fs1ZnzFYbqV8j06BsZQBl26/EPPGWwOUDRXBfZK78gix8ykbmhf+Alko1Z9PPijqSctM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619518457; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ekBNSaGAbkPoM4l+VTwHrOtr6ridwSwjQfLGetcTkbM=; b=UYmntmEtArzvddXSI6m1czvey3a0i4LOwBTjsWRf0NooDbAMI8w0nsu8xx629s5UgT3lyRBwZ5y01BDPPg5hfrsvhUbzA8+mM9V5M94zLBdHn0sv1YHYormtTtk5nkzV1hOnfl7FsGOJ1kmQzEvukoXq12T0qL7m8qX8Dim1oZI= 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 1619518457892507.4894090153831; Tue, 27 Apr 2021 03:14:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235666AbhD0KO6 (ORCPT ); Tue, 27 Apr 2021 06:14:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:34660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235192AbhD0KOe (ORCPT ); Tue, 27 Apr 2021 06:14:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0700E613D2; Tue, 27 Apr 2021 10:13:50 +0000 (UTC) Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKiy-000j5J-PP; Tue, 27 Apr 2021 12:13:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619518431; bh=euIQLwDaPDSgWFx6NM45FK2bpju26XjkPQY0ICj4Fck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDXaQwEUJm7SRklIGk3U2iLCY1FADzAXdT/tx110ICyofdHBH4XkcBq+fBiQze2vI MycMemIuwA8YahMx0PhnrbvcPQov7mxiMN69y46uQSjtsB6EeVVWbeZGlNhmDB+4za SVG1dtKWpFFzqPPMl66OQRx6KG2iRnVnpwyiAiq5ZAh5C23PQNpoHvFd6ILklfZpgC 6vxeBaMooh6tZpcENlZHZ2rtovWSFgX/eXx1O6wKsKOhU3hA1sGzIutd1A8z7s/NxZ CAI3pw8RX3QcC34v/NWzwAqC4SvU8XOxKZg3EmXkoi/f5NU37nwrGhmAyS/M0XiIjY haeddbi8qltGA== 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 v2 15/79] media: sh_vou: fix pm_runtime_get_sync() usage count Date: Tue, 27 Apr 2021 12:12:42 +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 error 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