Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9182766pxu; Mon, 28 Dec 2020 08:38:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXmInNug7cLIMEgyCb0qRlYNtpt6wuNlO20pPjbGj/C4Yw7WoiiDEJm4bU1/Yh8ndCI7Ax X-Received: by 2002:a17:906:4c55:: with SMTP id d21mr42570487ejw.116.1609173520836; Mon, 28 Dec 2020 08:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173520; cv=none; d=google.com; s=arc-20160816; b=bzDb/sR1pyuvuBxFxFs1iNkkSz9Mg3LK9qPfbZi45NLf99J1ORQtO0mFdunQbmTJqD 9fVGIdN+6m+CutflWbJr4acEFG+K6buss8JlZoxCZKv7nFO+PVaxUQkUjKYxNJySByjZ RQCoXudCRC1Op1KO+6M0p8aBrmPQeMLD3u6VlBjFOQWX1rjTyc9ZL1JrCBT8UJQrhF87 CZrpy7cadCZ/hPpXKXZqx1Lh7/g70pZHB8Pb4KCU/E4UfUQ0yIZN2wkPp84GK3w4tZnr XkToLQEy9+M/eCCxpgb2hMOWWPiWkLZvM7j3wobpl4OSHbTa0PuogTQpgssCiIBlOrVs X/UA== 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=O+iEhHZBFb5moXvNqi/yDV6tSYxXJK/KmiVq3EW7xnU=; b=Zf05GTROIbtEbYKwY70upFuF6i1oPUdbR71Penb0nnt8YZVWQ28lkZ5aMYGVYYNtS1 X7BanHzqdIDMX6hj5dP56FjQCgkPMdgYEeJES3/2wdE6e/2Hk6ZJ40gkMpdQ1iIQlyC8 +oRM/MwBMlW+0IEHqTl9NhpcQdUt2WJj6tyTGs33O1/lgZaeZA2NHZFOEYgR3JxulJ3/ oagMIdUSHE33CzMGUn8kw4YiQncy8LKzt+0RshZzjWzm9TcdEGJFNrenjeNHjMqA+hoB ReSrJQAwJ1FXxvA2SO3HJj0KGy6EK9twSGzr7qwwnqlxpHqBhYLTCM5dxAPo/ksWwrky l7WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R97YQfP2; 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 t15si19652127edq.100.2020.12.28.08.38.17; Mon, 28 Dec 2020 08:38:40 -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=R97YQfP2; 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 S2393673AbgL1Qfq (ORCPT + 99 others); Mon, 28 Dec 2020 11:35:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:58042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729933AbgL1NCB (ORCPT ); Mon, 28 Dec 2020 08:02:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4D193208BA; Mon, 28 Dec 2020 13:01:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160506; bh=hBqEKjtQH9pCeJpw+i2B+swTLS0iJvzOgIPDh8J/Cjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R97YQfP2UDbNQxYGKhJkPt0Uz2wbm1AWVMROhOnkN8yrjtiTyrAbv85XbinKqZ1zR hgTOpgTK+Up2OAUYOez78PIBeV68XfubmTRPHLAc3/0gMceu89kl+D2GrTred2MLgF pxCURJa8YrxN4v+6bnHH7ZNkV91mM/B5c3WKjVUs= 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 4.9 074/175] soc: ti: Fix reference imbalance in knav_dma_probe Date: Mon, 28 Dec 2020 13:48:47 +0100 Message-Id: <20201228124856.823088447@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 1a7b5caa127b5..b86bea4537325 100644 --- a/drivers/soc/ti/knav_dma.c +++ b/drivers/soc/ti/knav_dma.c @@ -752,8 +752,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 */ @@ -767,13 +768,21 @@ 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, &knav_dma_debug_ops); 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