Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3345702pxv; Sun, 4 Jul 2021 16:09:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIrvUMFrOz4m7cZoURCcmOFEy9q2LHcWRW/3mntR68cTfuAi9xONjvnTXS+EOUTVd8/fA8 X-Received: by 2002:a5e:a901:: with SMTP id c1mr9273371iod.29.1625440180913; Sun, 04 Jul 2021 16:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440180; cv=none; d=google.com; s=arc-20160816; b=km2Bft7N3+cHTYKOPxLiBlpZT9J60lfUgj/NR7+TsKhEJwfMP7EFDKeNg36CmjedSM ElqW2IOp/6oOK4yJI3aLJh/TfeDDIae8RWY7l21v60wdgnyZqY6xN8t2xCAJOCDalwMd k6NyW1iDSv2s42ooaBX5k+ztS5mNf77JT9RJXqvVYW+ihUtvHY7SOS+RZa9x02bkRgvK EKd7kGWoNdu34JxoQU5/l4lBmUftRoCGp/oGlW+ihQQFxMaPmeuRW0zvPfcxDQ71iEaK XuPbz1cOcUiEF1yzhmdKGd0ELJIRShRNOT8AnLDBokUjEYdYBmefHwGuT1g+sEIOBtBY VB7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ENZxCILcfiRnlrS+P0O70Uki/WX7a7z64Ehjn4ohKAY=; b=y2jooWm/uevqxrvRogJyzGFXEQBZC7wFdHV9KaOWFDSSdTKWa0/UU1m0RHFb2I3ivQ gYrDYUfPftdW0QR+SFvwv8SccJWyluWitarNQqjv1KXzb5M4RfXIRgCdxaKJJxi19qPY MeHBtx/j3F2NXsoB3ZsPIdd+iRuxO9O0QAGXkie8TbWztWmKdY9kdaOb9oaFzDRx5SBw 30OhT55Bpa0PtyC5TJri3k4okqEAUDO4M2T3Mt0nj9YfiIodCKH0DRBR+bHmar6+W4QG ZjX2Fy2/Fgoor7LI3yKo0BuDgXVUAqe6hvKloG5S86OgpTdcSY6aaTBCmXjUayNyy+Me gcBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B03aSRjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si11528147jas.89.2021.07.04.16.09.29; Sun, 04 Jul 2021 16:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B03aSRjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbhGDXKL (ORCPT + 99 others); Sun, 4 Jul 2021 19:10:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:47420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231747AbhGDXJE (ORCPT ); Sun, 4 Jul 2021 19:09:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 034FA61364; Sun, 4 Jul 2021 23:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439988; bh=9I4P98nw/TH7inHBdRHqWHOLI2uqRL4qTkQnABJ42dA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B03aSRjU23rTMtsn7bAopyYhx6HmsrXK6I0LRMTMLFt8NrbLZL/foA0NmROmukz/C ST5Q7HjSN7HwCc+ImP4kMgAtog5MvLod+TjY25+kErkY+0U3FFGb6FOLTi7EyVXpuV 6iR1kLkb7J4pIDxsefiivXxTKY0pKjj9qVzBQs3pZUHYHdLP+z3PxynX+97sWEcFf2 dmRIUJuFNQHUlkNBtVIMK1AQMU4JY/p+BlbIRYqr1aacqHmJeXyf7O/BgdF1IDC/5g krcVdzl0svKAev45Joo2I99Zqy2lWnvSZF9qs9yqVy7YXtfioHS4QXURKfeAwOZn2l sIgPpA5haXDTw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 09/80] media: sh_vou: fix pm_runtime_get_sync() usage count Date: Sun, 4 Jul 2021 19:05:05 -0400 Message-Id: <20210704230616.1489200-9-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab [ Upstream commit 6e8b1526db164c9d4b9dacfb9bc48e365d7c4860 ] 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 open time. Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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_vou.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 == SH_VOU_INITIALISING) { /* First open */ - pm_runtime_get_sync(vou_dev->v4l2_dev.dev); + err = pm_runtime_resume_and_get(vou_dev->v4l2_dev.dev); + if (err < 0) { + v4l2_fh_release(file); + goto done_open; + } err = sh_vou_hw_init(vou_dev); if (err < 0) { pm_runtime_put(vou_dev->v4l2_dev.dev); -- 2.30.2