From patchwork Tue Oct 27 13:47:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 289735 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 93B47C8300A for ; Tue, 27 Oct 2020 15:27:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50AE92064B for ; Tue, 27 Oct 2020 15:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812451; bh=ipHvzcX42wBYYnwHI70OxBqJ5XCYoQQwOnR/I7HYPcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HuhUzcraXcJ1/pxrqSy9MrlyxFCGtW41JQjjissIJjd+bmDYDrWz1penyn47yRegc wY24q11essGopcfWKKDJPXFEttxkljoxCuQLL5UyBSgZfvVhOAEQNCWs2D7l+WHEQt 3gBUag1s3HZShyQld7MDShjZ0ZeiXTDMZZRxclDo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2901295AbgJ0P11 (ORCPT ); Tue, 27 Oct 2020 11:27:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1798122AbgJ0PZd (ORCPT ); Tue, 27 Oct 2020 11:25:33 -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 7744F2064B; Tue, 27 Oct 2020 15:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812333; bh=ipHvzcX42wBYYnwHI70OxBqJ5XCYoQQwOnR/I7HYPcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wQgyEzEJ4IE3FqW3sZHNkkIH9v5QAyUy7lTM7GzJQrLcsp2vsfYq2pMgayJanrju0 6TuJ4o4SpJ1cs0xkCx1bCU+rfkoCX5vGgHAxEwI4fz3BZB21bGPH0DNXJTrDMCZwKL gAiQeb+6BUGAPcwuihDMjVRGYf66JxSCJ02beyDU= 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 5.9 171/757] media: stm32-dcmi: Fix a reference count leak Date: Tue, 27 Oct 2020 14:47:01 +0100 Message-Id: <20201027135458.614808943@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qiushi Wu [ Upstream commit 88f50a05f907d96a27a9ce3cc9e8cbb91a6f0f22 ] Calling pm_runtime_get_sync increments the counter even in case of failure, causing incorrect ref count if pm_runtime_put is not called in error handling paths. Thus replace the jump target "err_release_buffers" by "err_pm_putw". Fixes: 152e0bf60219 ("media: stm32-dcmi: add power saving support") Signed-off-by: Qiushi Wu Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/stm32/stm32-dcmi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index b8931490b83b7..fd1c41cba52fc 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -733,7 +733,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) if (ret < 0) { dev_err(dcmi->dev, "%s: Failed to start streaming, cannot get sync (%d)\n", __func__, ret); - goto err_release_buffers; + goto err_pm_put; } ret = media_pipeline_start(&dcmi->vdev->entity, &dcmi->pipeline); @@ -837,8 +837,6 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) err_pm_put: pm_runtime_put(dcmi->dev); - -err_release_buffers: spin_lock_irq(&dcmi->irqlock); /* * Return all buffers to vb2 in QUEUED state.