Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1941961pxy; Fri, 23 Apr 2021 23:47:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0KxVSxXZzxEkBdgO3uGgVRm5fLYQq2tp7wj2ZbwjtTp1/jErC5hXpeU1kaTDDpaaGLFZr X-Received: by 2002:a50:fc02:: with SMTP id i2mr7308edr.320.1619246860949; Fri, 23 Apr 2021 23:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619246860; cv=none; d=google.com; s=arc-20160816; b=r4AOwaLbYqDpKL1K4FJiqmPAme/BHQV+OtwN4rgtHeEQVpttoZlIudYHHlMrHt6ZMl tISVkt5qrzlS7XDxF1lX529sA32vvAbw3/lnmjNQTw56Ez+sc61ETB3m4hMkr1dnlYBM LMu72+r2Wkf8NJSPH3OHNV+m/bp0JqY+w3Halc0XlpuQCGO61KV6+1kB544OuZbUXQzx 4D5+Sjb9TgQ6WoZ0nP0PSwIJmTt5/LLKIGsXi3WADK5XOcHRz0FexTt8eFo4vwPMM7np 8w2+4dOyHc3tiVs/uymKQiSMoWmm8P3+9HizDFpKUV1NXIvCeD4eRPOgywAHgs0UNcuD wBNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=wqxIfOPAQD6fb6jWFEvwvf3bz5V9XDtsbEn4RRl5u0E=; b=EMfCDvCKETWo6Re9hIAex5K15LAuxzD3FTVmHxvTcBD5JH7l7+ji5vp4cqfGEfQr59 4KY4e+YqF5ve2htaOh6fCK/tNw0ole/loF/8rWgymuyjQBgXLdjU4PwNiS8XMQTDlPl2 FE3vsAybrPSz68UtmsoccNCQW1M16cOtINJ79UWfrTongTIuhoHSy41FMDtrS28a2vaJ YGQjQxKp7wBNZJbqaquav3AIxW1r6Fx5+HHFPBjJ1kqHC9wIoiL7kOZeS/NWkcMJJplX U2ue6aFZdj34/VnDaNizPAS4GJkAWimUQEzgFc4F+/e8+mpKfFYenW/uy06u7BXUIFYD 5Udg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=T3cWwAl1; 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 mb19si7827239ejb.553.2021.04.23.23.47.17; Fri, 23 Apr 2021 23:47: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=fail header.i=@kernel.org header.s=k20201202 header.b=T3cWwAl1; 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 S237276AbhDXGqq (ORCPT + 99 others); Sat, 24 Apr 2021 02:46:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:35766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231467AbhDXGqM (ORCPT ); Sat, 24 Apr 2021 02:46:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 05D5861492; Sat, 24 Apr 2021 06:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619246733; bh=CEyymY4/rjVCo+aFrsQVbMV0NkXC9qbuhSIFfneK2dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3cWwAl1vyVm77GVb6CNAu4mqCxFefBHk72chkY7qihZiy72NH46UMnelgEvu5DI9 orweLgePkbUar+wJ4mwLj+4FEKmMwxzKWFr2fs1Y0LBgxBBS9bd5wgRlpIy5f9Jbcj C0iMThTi1fhA8tF56SlrMHiijR2aS1Heuc0805czBssKmZqJ5gTyX8H64riwlvbUoG K9a7rRLNdDFk83BqoDqoR2aXZRlARvtGsvIWCN836H1YQtMk8jG1Apq9gLpMjn3+jD DSwjNCpoeoJ+kCv7MJNlm40nyf+SNIPOoJDfUV0/upkieUhSd6H6TDaja86lBDDl29 4hcKAQpoMLHcA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1laC2l-004Je0-1X; Sat, 24 Apr 2021 08:45:31 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Jacopo Mondi , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH 06/78] media: renesas-ceu: fix pm_runtime_get_sync() usage count Date: Sat, 24 Apr 2021 08:44:16 +0200 Message-Id: <29ba3fafde4d2643fae49789e6b378d6b1fd51f5.1619191723.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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/renesas-ceu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c index cd137101d41e..965a7259e707 100644 --- a/drivers/media/platform/renesas-ceu.c +++ b/drivers/media/platform/renesas-ceu.c @@ -1099,7 +1099,10 @@ static int ceu_open(struct file *file) mutex_lock(&ceudev->mlock); /* Causes soft-reset and sensor power on on first open */ - pm_runtime_get_sync(ceudev->dev); + ret = pm_runtime_resume_and_get(ceudev->dev); + if (ret < 0) + return ret; + mutex_unlock(&ceudev->mlock); return 0; -- 2.30.2