From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE41CC433DF for ; Sun, 18 Oct 2020 19:27:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73256222C8 for ; Sun, 18 Oct 2020 19:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603049226; bh=Vo+laG5Ggs6g5JM9vdCdYDWFcwDE4twWzBeZlukLv04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=o85AQ1NhO6lis7eJL4AiUsyqM3fCqBaVUQ01tGhH529kL4pMAwEJ53hdSuV0uDqvp f4CNRYKpyKjaqDlBkBhaVnMkoHOl0kiqARvL7T/exeqqQ0Y6dbINkZixJxiZ//Bkph rsIdbyouBuPy6XKFnW73q2SKeXnPL3Vdy1N5jNA4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730684AbgJRT1F (ORCPT ); Sun, 18 Oct 2020 15:27:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:42010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731796AbgJRT0n (ORCPT ); Sun, 18 Oct 2020 15:26:43 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2544C222EB; Sun, 18 Oct 2020 19:26:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603049203; bh=Vo+laG5Ggs6g5JM9vdCdYDWFcwDE4twWzBeZlukLv04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xBAX41yIxnXKvFyIG/YDyPcYBdZR+HJeXP+SWZZOV5H4Q3kl+WLGaNuzY8A3//eHa ts+S0lCpioV3HAaJJ0rQzZm0hb+oyVrvRTzGGUvCkzTVmWcQo24WAHz7hwpUfaj+6q 23CK5gLQ1rsqWazYMlDG4JtAhFjqQ0uJ1UI9sLGA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qiushi Wu , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 05/41] media: exynos4-is: Fix a reference count leak due to pm_runtime_get_sync Date: Sun, 18 Oct 2020 15:25:59 -0400 Message-Id: <20201018192635.4056198-5-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201018192635.4056198-1-sashal@kernel.org> References: <20201018192635.4056198-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: Qiushi Wu [ Upstream commit c47f7c779ef0458a58583f00c9ed71b7f5a4d0a2 ] On calling pm_runtime_get_sync() the reference count of the device is incremented. In case of failure, decrement the reference count before returning the error. Signed-off-by: Qiushi Wu Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/exynos4-is/media-dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index cdaf3a8e2555e..b0289fca854cd 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -477,8 +477,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) return -ENXIO; ret = pm_runtime_get_sync(fmd->pmf); - if (ret < 0) + if (ret < 0) { + pm_runtime_put(fmd->pmf); return ret; + } fmd->num_sensors = 0; -- 2.25.1