Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3345817pxv; Sun, 4 Jul 2021 16:09:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI4hPILjKvrHVSJF+hgffnNZSzqeh6B2PnVxLi0kKxqRUMjaXg9KFd7RoWPnSeSzDYOc8G X-Received: by 2002:a05:6638:43:: with SMTP id a3mr9666568jap.41.1625440194918; Sun, 04 Jul 2021 16:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440194; cv=none; d=google.com; s=arc-20160816; b=rfriN9RxHrUPhv6wrbKkOngY0xwBzLHe4iBuYlV8D9t3EiOCSlP2diUrg7xqPnWMVV 2GehQM9fsa9etNp0iB/gT2U1iMLnd/AZNS8U0DTIFfx0Tb638qDvefw4GLSpuW2eDx8M REYMe7CJsOYB4WB3CfUR0D5cEqOCvZmkn+gv3b/M70zr63NDAE+k3U+oFJQ1ghzAcP31 oZ4erqJFLmaSUIKDydjACZFb5/73UQcht9VnHZXPHi1o0HxxEsgY4XFC0IjrnH6ZpZZu UhHUNVnP2hINPdCRSZZnXC/rOSHjnm4FvrMfcnTjwiI5mpMGLCGpys+dd7AlPk5a7wlM iJAQ== 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=rekJXO/q9Woo/AOeA4h4jNNXq7EY3WOat91YV8tvB/4=; b=HIxYyZIrywoIcME9rr3rA7efG0/V4VVn5XEY5wGCfljVbihKyNiWsi0StlfLNPzD0L zTiMmmdsNE//7zfkkcX0dvuaBf+dtWC2EE0xFZx+tRVL5sH1NQcLy8dNpOiV+wpHPCTb sOLJnlXAJn8bpSCped1Kzc7DcjMb4oHF4mvTTmIRbynTkMZ7Rxifze6Oa8OQJKt7YVv3 QV7iYHrZJSLX0dThfJa4PFIDrctJy+qGYFEgjUNs4eM4pg/6BhD/iDgR1+MpYpgjAVq4 T9Nis491kl7c49fFAG0XiQnIAnbArpz432/BITCbQHgumNHmx3L+HZsj52rvPSeee722 gVTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lls0rlpX; 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 f3si11370215ilq.115.2021.07.04.16.09.42; Sun, 04 Jul 2021 16:09:54 -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=lls0rlpX; 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 S232216AbhGDXKG (ORCPT + 99 others); Sun, 4 Jul 2021 19:10:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbhGDXJC (ORCPT ); Sun, 4 Jul 2021 19:09:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 79CED61283; Sun, 4 Jul 2021 23:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439986; bh=Lz+/JlLUf0y6vdpM5zzN5Pg+5vyv1ERRqgWrhzFUI5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lls0rlpXPa9rgkC/6n/DQ0rbomZ/+doSazSrvSUpI49RARjy8hyWVICo0PkYciTXj 3FZyYsM9gdZR60dxOsqi386QsEsxX78zxHsgAy1mFHDEO/5GQkPwPmJGK10DFErNUS WgbydxMaNqzcjUBIeFCtfzDeOTu6YO+h71I2jUa/U/y3b84F2vKidSow7wGPXjuD6I t5Z1NTLWXpQqeSj5eu34kF9xF8ztj6T58dGDlP0g/DtJ12LxAarumYT3JCg7KhGwDy W9cRelz0wInqqCWfDyGn4Q/lV41LwEECVY5BpdfGigO9Fsl3Gh16apARsWd1zIb9rS azWM0+AYx/VHQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Sylwester Nawrocki , Marek Szyprowski , Sasha Levin , linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 07/80] media: s5p: fix pm_runtime_get_sync() usage count Date: Sun, 4 Jul 2021 19:05:03 -0400 Message-Id: <20210704230616.1489200-7-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 fdc34e82c0f968ac4c157bd3d8c299ebc24c9c63 ] 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 s5p_cec_adap_enable(). Reviewed-by: Jonathan Cameron Reviewed-by: Sylwester Nawrocki Acked-by: Marek Szyprowski Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/cec/platform/s5p/s5p_cec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/cec/platform/s5p/s5p_cec.c b/drivers/media/cec/platform/s5p/s5p_cec.c index 2a3e7ffefe0a..2250c1cbc64e 100644 --- a/drivers/media/cec/platform/s5p/s5p_cec.c +++ b/drivers/media/cec/platform/s5p/s5p_cec.c @@ -35,10 +35,13 @@ MODULE_PARM_DESC(debug, "debug level (0-2)"); static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable) { + int ret; struct s5p_cec_dev *cec = cec_get_drvdata(adap); if (enable) { - pm_runtime_get_sync(cec->dev); + ret = pm_runtime_resume_and_get(cec->dev); + if (ret < 0) + return ret; s5p_cec_reset(cec); -- 2.30.2