Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp180611pxx; Wed, 28 Oct 2020 01:52:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuIArZ6XQ+/5f53kTVs2t1tDgmtVM9n4QZsvxj/llUp2RdX73DoDsBLRKX4Hxpytl0s6i8 X-Received: by 2002:a17:906:b150:: with SMTP id bt16mr6736708ejb.257.1603875133277; Wed, 28 Oct 2020 01:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603875133; cv=none; d=google.com; s=arc-20160816; b=koHJe3EU/ywpviOreYAdkk+qirA/N8VZ0UnZNHzhFMxCIEKTxit6+UYwMMVuebspHI z3K4vEPeBTHVrKnc6c6JA/MHy0YGsHQfGuDK3g66F3czvkDg612i/vbS8rwpWb79y5wc Li8yubCe7jhQQ7ZU2bxXikmezTUZICyJtD1dwq6/rHuJ67CnnjPk3HZdouFNXehYF02+ 9AVPUhOT6zk7sEl62HME9l1vsplNRO4whTNfkcY4Txwz5yHE/yz9stLmmn9b+dNpwNW+ Ry/T98DUgR32BQl85K5bnuAyrL/F45v7En/1WweyomXFxMy+2sXeofpQOKKWAg33/6M0 T1Jg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nwMuxXuSKF7KF+IXTjvPuNBYhlkUtpoQARBGnfyQ7UU=; b=01MWil7fN4oe4ZoOGoU/xcN7Jt//DeTN9haIPIHV4RxeG/7JBBCxtbOTLY+qf6+09+ xx9Nu/QDLhzCWK/NjGwBzgWPJRdljgLmbNM3TY71kFBxV40/8mxWogas5Xecu46LbAwl RdNUM/uTzkSYt2faFx27VSX7Zwto+5eajxa8xpZ4jVf+6/wnGW7bzH5XQLpbOjI0xzst hKs1MhJ+0V27Zt8VDWxZ/jadp5uemRZe8DuodF+XMWrjOSw2R9gqYXFwgqzywz5vatfl 7000yC+b9iTWgkUieli5OeCvIeXOX8TX3Mve7oZdGq4MMAkGnO+3dW6PFpBdLbCyqhbr A6bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ifqF6I2f; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si2524555edb.466.2020.10.28.01.51.51; Wed, 28 Oct 2020 01:52:13 -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=default header.b=ifqF6I2f; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756460AbgJ0ONY (ORCPT + 99 others); Tue, 27 Oct 2020 10:13:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754959AbgJ0OHt (ORCPT ); Tue, 27 Oct 2020 10:07:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 857D6206D4; Tue, 27 Oct 2020 14:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807669; bh=y1xu6YN5n8PCbz6xT8fVPb2HFgWucIGP9wF1PWqUmCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ifqF6I2flrgBy6o0BOdE08/i5T9ErYXOERKwbk2govFJbVKpeKRfSEuPnCk3YLiqy 4QAbgrfeY2GWKf++xvZDA+5n/avYmh5/jE43R9i9f/EJrAqrWP27DqsJFW0HOeFTwB CUDhi6LiSBZyaLLZu6gj8BKCq2B93VT9mHJ6f/5M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.9 097/139] media: exynos4-is: Fix several reference count leaks due to pm_runtime_get_sync Date: Tue, 27 Oct 2020 14:49:51 +0100 Message-Id: <20201027134906.740542649@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiushi Wu [ Upstream commit 7ef64ceea0008c17e94a8a2c60c5d6d46f481996 ] 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/fimc-isp.c | 4 +++- drivers/media/platform/exynos4-is/fimc-lite.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index 8efe9160ab346..dbc4f57f34a52 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -311,8 +311,10 @@ static int fimc_isp_subdev_s_power(struct v4l2_subdev *sd, int on) if (on) { ret = pm_runtime_get_sync(&is->pdev->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put(&is->pdev->dev); return ret; + } set_bit(IS_ST_PWR_ON, &is->state); ret = fimc_is_start_firmware(is); diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index b91abf1c4d43b..f1921e06ffe1b 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -480,7 +480,7 @@ static int fimc_lite_open(struct file *file) set_bit(ST_FLITE_IN_USE, &fimc->state); ret = pm_runtime_get_sync(&fimc->pdev->dev); if (ret < 0) - goto unlock; + goto err_pm; ret = v4l2_fh_open(file); if (ret < 0) -- 2.25.1