Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9173782pxu; Mon, 28 Dec 2020 08:24:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQPnrL6+fSFruyeos+f+f+1SjiX2pgTySVoJ1RkpRnfizkL+ylwObmzEALDgWJV4KlDxc+ X-Received: by 2002:a17:907:1010:: with SMTP id ox16mr42627353ejb.439.1609172672608; Mon, 28 Dec 2020 08:24:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172672; cv=none; d=google.com; s=arc-20160816; b=pG73Qn1x/ScW15K+XSeVBZCJSK1M51KUk4jWutmwEscISySA9ZqqygxMr1Sq8KFMwS Z3aBg0gYqSYUrB22LEVyAAWGqMJAJBoAUTETSDUvHR82H+MlD7GqzRYw/aoFn2vy7VrM bOcje7e5Dzub3OdoYaXtd1PuO4TRMTgmq5NoY/Z1QqXRukKt6RcaxrHc1YC4HzEttOCH Ewu3uTc7trxMJHaDix/KkaDWnGPhWW1a6OrCry5o2DvzX5BsddQMc2VYmML+IjAunA/7 JqSWL94wXoVM66tAO2oowZZFzbNWAluSKdShME6sn8uf73JuXR/ii4/Va5gk0wfOPD5P X1pw== 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=j4KRSsXz5ysMKsSZAxdq1Cno7yCoHylsYn772EazFyY=; b=xvYroPyu6qFgt56Gr79gWnfaS4SM3Lvr2gM4/Df9jzffzxhgCM+bTM6XqjeRjE2v+x O/5K140XjqjF8cApewdjnwTyGH2IoVUQfLvIdZXhSnSLjtjZHs34dU2xz9ytWt1yw6oQ aGY0te1XF5tbnxg+nQlYhbXiRXdt/7lcvphto/s5VOwzcE+b4m6k6FOF0X/IDvoviXIJ ymAmar/BL48XUwggDqUxMM1ZalGnuGJ5+9BABb8xgUVOuUDs5HrmYNvWo97jwuOUslpa hWwsTXXQTw0JSV/tQiT8nTpXhKoSUZlqQ7LRwjdBWXO+9c8+RE9oldqfig2xEEEkXhbE sqMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R0QMsaSd; 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 bm3si19322426edb.188.2020.12.28.08.24.07; Mon, 28 Dec 2020 08:24:32 -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=R0QMsaSd; 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 S1732189AbgL1QVj (ORCPT + 99 others); Mon, 28 Dec 2020 11:21:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:40494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731979AbgL1NMc (ORCPT ); Mon, 28 Dec 2020 08:12:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6F0F622AAD; Mon, 28 Dec 2020 13:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161112; bh=rrjyuu1a81qFMjw0tQpoLJWGqdWaC2DZyQqDUlSfIWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R0QMsaSd8lxWYIWNJlUdFLn3TnOmJfydJO7YX0wgK3o6ygMGmv0pGuKrSb6tdSzPZ Ih/etr/PQ3M5xp8J5QjcVICWmNwkvaDzoKbExtStaAmXRBdmnosrnnXCLtawylQ8VW dH3Zx4nhF0cjvBEU0EQ4QmufUxVtehQ1StqyqYW0= 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.14 103/242] soc: ti: Fix reference imbalance in knav_dma_probe Date: Mon, 28 Dec 2020 13:48:28 +0100 Message-Id: <20201228124909.762988531@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 026182d3b27c1..6d137b1f43ae5 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