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=-10.0 required=3.0 tests=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=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 F2A00C433E1 for ; Tue, 23 Jun 2020 20:56:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2AD720724 for ; Tue, 23 Jun 2020 20:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945790; bh=P7Zj5uhIc+JZTURYcuj4UOGI4By+g642Ems2BbGhayE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=m2l1HRNx0D0EmYe8sNuoTYoDSGDxkbRYGjx2kvX4DvMvD3Ulm2mpMKZ8ZSNKZXYs6 cix/9lqzU+BZU2+osn4SG73oSU135UmFvSWJUxaY7J7UYRwrq5FN5tLAf0Fs+MGJf3 wu5hincLxrWAvOxzTwlniidzdEoTbFvqFKVm7e2I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392549AbgFWUnp (ORCPT ); Tue, 23 Jun 2020 16:43:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:40696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392547AbgFWUnp (ORCPT ); Tue, 23 Jun 2020 16:43:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 3772F21941; Tue, 23 Jun 2020 20:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945024; bh=P7Zj5uhIc+JZTURYcuj4UOGI4By+g642Ems2BbGhayE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Ke0qt0vj20rlbFN7LewcNgVipNRr7lKb63exHjKBVFpDedWEyzeKnY2E5iRBX0Z8 BVsrcC5t9XfqH44jhgJSy/nHPTMTk2vGX8SXN1NeOIvPZgrsIbaKJ3WkhcKMKwVqjg F/MCW2MtV6rxCwtrsN1nJ28HUqVLGQAGZpIuQYeY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiyu Yang , Xin Tan , Peter Ujfalusi , Mark Brown , Sasha Levin Subject: [PATCH 4.14 010/136] ASoC: davinci-mcasp: Fix dma_chan refcnt leak when getting dma type Date: Tue, 23 Jun 2020 21:57:46 +0200 Message-Id: <20200623195304.127526861@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xiyu Yang [ Upstream commit a697ae6ea56e23397341b027098c1b11d9ab13da ] davinci_mcasp_get_dma_type() invokes dma_request_chan(), which returns a reference of the specified dma_chan object to "chan" with increased refcnt. When davinci_mcasp_get_dma_type() returns, local variable "chan" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in one exception handling path of davinci_mcasp_get_dma_type(). When chan device is NULL, the function forgets to decrease the refcnt increased by dma_request_chan(), causing a refcnt leak. Fix this issue by calling dma_release_channel() when chan device is NULL. Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Acked-by: Peter Ujfalusi Link: https://lore.kernel.org/r/1587818916-38730-1-git-send-email-xiyuyang19@fudan.edu.cn Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/davinci/davinci-mcasp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index e10e03800cce5..6991718d7c8a2 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1747,8 +1747,10 @@ static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp) PTR_ERR(chan)); return PTR_ERR(chan); } - if (WARN_ON(!chan->device || !chan->device->dev)) + if (WARN_ON(!chan->device || !chan->device->dev)) { + dma_release_channel(chan); return -EINVAL; + } if (chan->device->dev->of_node) ret = of_property_read_string(chan->device->dev->of_node, -- 2.25.1