Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9081887pxu; Mon, 28 Dec 2020 06:12:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1q//XJ4XvfmvccHols6L1UwRLw/pG8giyi4b1E0mQ9lSCghJzq36sV5M5sHW3WziDNlNM X-Received: by 2002:a17:906:fb1a:: with SMTP id lz26mr41542319ejb.194.1609164725822; Mon, 28 Dec 2020 06:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609164725; cv=none; d=google.com; s=arc-20160816; b=SZlmYJNBWcmEfMDnWGlgI387docroe+l6hMHhxRT14VjSW2w+903GkJD0r6TMR2to0 aLaovjjAhBvAKVnB4mU6cTknTZCJ17MgRDIuod37+4U42+Sti+zSjfom2lRN2I7jpBXC wNZruYUwslY7v+NfNSX5x/bjJx914ZEINi7wVhF2abqYh8+xQ7cD8zfoZIVqDa3TQWv4 42sJIQo94ne1HLOlu5wFUxJ8vNlAclmbdACnhi4pMTnH3HJGjnbpZcqgckt4EhDESFwC t+dtWoRCQZZMCAS8O4TKgCVIH7gJv80SMCIyvDBopNRA5hVi/Se54aignu4f2p1ZE99L DGOQ== 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=wQR9J/ccenIHAOJJDAaeqt4UaJsiT8+RpGQxUu8kCIM=; b=0f4ytMpaPkeDupXNET5NkxM9KLota9fo3tUy7PByqcQ+dAGqG8/osSuG5Wpn9ud7W3 ynXN4NtvMbljZSUFzlFJwmIxtKSJfXdHifL4U0vM5TXMzGQDHUHOHOEeZx2F7Vc/40VF ODlXaLAYblw+nLo04uoL/N6KnQ38Tzp4t1CzMsGXotYv+iXtcDfbpKWXggril7pxrlFD rxQpP3NYXcbFrop+bAsW5DCcAg7dbTSq4X6p3ik1uvpktxJFF2B4xUt55e7k2XJTB0pv KYuizoB7uiffNVBLrfcRFuhp7HZtYSdQOlzFKXAmjPZS8g5DRvItVz71ik/mtKFJvYjz 6cIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZYIclFY9; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si18796286ejg.642.2020.12.28.06.11.43; Mon, 28 Dec 2020 06:12:05 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=ZYIclFY9; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438836AbgL1OJi (ORCPT + 99 others); Mon, 28 Dec 2020 09:09:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:44116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438834AbgL1OJh (ORCPT ); Mon, 28 Dec 2020 09:09:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id ACED922D02; Mon, 28 Dec 2020 14:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164536; bh=5JPo39xMLtD+LD/bvrTjNMmjCmfjoxWqlRKgiSODFgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZYIclFY9igZd+Na+RV7hJUYS6eW5xrlGLidV172V624bpI4/nZwhqV4WjBe2pHzbz J+YMHCX3bcFBCElz5d8ksRK8l4KGCIZ+tY7abt9tEvsBVyE/Z5RCdpKNTYCgB3pLv8 JVKteEj2ZPMZRlOo9Ln3KtCCOiU/5/v9JNUd1Rmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Santosh Shilimkar , Sasha Levin Subject: [PATCH 5.10 179/717] soc: ti: Fix reference imbalance in knav_dma_probe Date: Mon, 28 Dec 2020 13:42:57 +0100 Message-Id: <20201228125029.542530349@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Zhang Qilong [ Upstream commit b4fa73358c306d747a2200aec6f7acb97e5750e6 ] The patch fix two reference leak. 1) pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to call put operation will result in reference leak. 2) The pm_runtime_enable will increase power disable depth. Thus a pairing decrement is needed on the error handling path to keep it balanced. We fix it by: 1) adding call pm_runtime_put_noidle or pm_runtime_put_sync in error handling. 2) adding pm_runtime_disable in error handling, to keep usage counter and disable depth balanced. Fixes: 88139ed030583 ("soc: ti: add Keystone Navigator DMA support") Signed-off-by: Zhang Qilong Signed-off-by: Santosh Shilimkar Signed-off-by: Sasha Levin --- drivers/soc/ti/knav_dma.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c index 8c863ecb1c605..56597f6ea666a 100644 --- a/drivers/soc/ti/knav_dma.c +++ b/drivers/soc/ti/knav_dma.c @@ -749,8 +749,9 @@ static int knav_dma_probe(struct platform_device *pdev) pm_runtime_enable(kdev->dev); ret = pm_runtime_get_sync(kdev->dev); if (ret < 0) { + pm_runtime_put_noidle(kdev->dev); dev_err(kdev->dev, "unable to enable pktdma, err %d\n", ret); - return ret; + goto err_pm_disable; } /* Initialise all packet dmas */ @@ -764,7 +765,8 @@ static int knav_dma_probe(struct platform_device *pdev) if (list_empty(&kdev->list)) { dev_err(dev, "no valid dma instance\n"); - return -ENODEV; + ret = -ENODEV; + goto err_put_sync; } debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL, @@ -772,6 +774,13 @@ static int knav_dma_probe(struct platform_device *pdev) device_ready = true; return ret; + +err_put_sync: + pm_runtime_put_sync(kdev->dev); +err_pm_disable: + pm_runtime_disable(kdev->dev); + + return ret; } static int knav_dma_remove(struct platform_device *pdev) -- 2.27.0