Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3343404pxv; Sun, 4 Jul 2021 16:05:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdiniB2GmOnf2knwMqg2fsX9wNBo+KIG1Sh/ScwVt1+I9lJpqfpIvCUPjtI/LYqKgO8p7J X-Received: by 2002:a92:c612:: with SMTP id p18mr8216504ilm.54.1625439921987; Sun, 04 Jul 2021 16:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625439921; cv=none; d=google.com; s=arc-20160816; b=Tk668HdtWbWTTpo74laG44lfcPxWWdUHKP/b0gTxdsQTRW/H642BecCEleEzM5/qdj kmG7TQAOTpBicKi2D6TZLM8oZQTHmcOrIL/+13mH4biAYpCdHjNHganTkrPCBZUDFJv1 0ZH20tXGkeWi5TnXnlt6WWr1IULu3G7E6kJhs3XiHd4Q0+YVCDYRNTJCrcEP8whJFR38 dQCLIezVuje237KX8L/N54tmgwgjP/PJNuSnl6vhGQ7YcU32hcd8EBET4JU6FE5aT7/S LpKVyOWaJqCYC85ZDr0Mm/YKjEDVrtJsb/qE4JECaMtPQaMVXXR12foOJOyhSKgmUCbk WRnw== 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=nR5OR/4qQ+Bnrrw45a5McQgJw55ULk0YUXLPlQEqOqORuxyewNYWU9/imR9Sefzbyd bRyMqFt43ZDE9K5o2b2hoZOMRsZL+tMmv2iIezShCVd/5YJgj56ZN/lZTVs2aB5wcb0u iKvJbVzt/MG/ftfQPq57E4UTQYk3i7llhOjli0jE+OJFAAXJglBODwdm5dRj2iP2Fltv 9Uyk4fo8AmCKX4wH12InzmvzxdrL0tR4heBUF/nVaNnTva2PGVvGdDghcMIHEcc4ZO8q vz5BVyerPMQuWWYEnfV5IMdBUCYOmu+uRntP4XbaCHBMrvXeKMcjoLXMlILDJgEFLwL6 CVdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pDBzVMZC; 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 z6si12929067ilz.73.2021.07.04.16.05.10; Sun, 04 Jul 2021 16:05:21 -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=pDBzVMZC; 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 S229970AbhGDXHK (ORCPT + 99 others); Sun, 4 Jul 2021 19:07:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:45048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbhGDXHH (ORCPT ); Sun, 4 Jul 2021 19:07:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1223761283; Sun, 4 Jul 2021 23:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439871; bh=Lz+/JlLUf0y6vdpM5zzN5Pg+5vyv1ERRqgWrhzFUI5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pDBzVMZCpYWL7kFR/jW5nOiW0ECZnFgq888zCES31Ks92bNjvyYS6e3+2H+HiMOjf EcdRUV48/ghYPSF7Ptr0oSiqYtbNZg117p38fmXHna73UhnuBAu3a148hZE/RUBmRX ozOMS+03E75fofvBMHYJcy5XfgZSlFOHhPl6GJb5w01WzPQrpt4yLyi3bRrZc8Dt6M 43bl7uK5dH76dLGazB4O0OLwCrd9fiLa0Ovb8BX0dsWkMKaxBxeuwawTKiaTZ17jmS 0YuJTrQ3E/yGH7xXMsgsDO2+tHt1bq51EwciWKDyLKvMB62GqG3XqGhDmbh5EeDTon kZ4rWr3KhJGrg== 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.13 07/85] media: s5p: fix pm_runtime_get_sync() usage count Date: Sun, 4 Jul 2021 19:03:02 -0400 Message-Id: <20210704230420.1488358-7-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-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