Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9085415pxu; Mon, 28 Dec 2020 06:16:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW+FjSw2b67/AL+gPgTj4mcNIj/gPWSHsuITFReb0R5uxRt2IJICTzjXZr5Wugi1DhPXt/ X-Received: by 2002:a17:906:b7cc:: with SMTP id fy12mr42015760ejb.44.1609165006562; Mon, 28 Dec 2020 06:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165006; cv=none; d=google.com; s=arc-20160816; b=lnQjPsFzh8+pNCnu/v1w6zWfznk+EkWFYiiugJ41S63jFP1Y5PeyvwVcEbXpOJTvim BTD2vSjyxto8In/4kGP4SFUk1lPa9o+0upNz82QGkG9kZm0/NLh6I5X+AxX9P9fXwtJF Yy/JtHvXS/ptyF6Xteg0SD6pOeUSWwLbwDu0CBX1iiCYbQhCABXRnJePLmQQkoZsu7ql SzfRC7aGIoq0EpBKhEBuA62v/qzN92QRTJQ0n0eHeS2AKiOB4hIQaXbxGNskMYpnZ1oF i3DVojaa9SX740X2yhy6YJ9CHkVjdjnO/07om2Vtc1WjAz17nFPSmi5ZM5UTQztRax89 7Hdw== 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=QPP10K5iqDM3DMUaPHJjmEYa5porMwRgONrgX6RQDRg=; b=nfMWhe0k4hVAzEQUFj21RWVm7UpTtEo25e/xtf2cALZO4ZIGQUKt6MjMlglbX8iAXf 3KhIyp1G6PZK6HjJZnt0oubb+ue7oNvPI4KxFPn28FsbZF30/30+2AL5k03hqWPFThUd pOegfax8w6eloWIJRwz6p5rGZ/RUzRLK6jF7RE9ADy3xH5hCDvoCr8Vui3K+EP27wedf WrzqR1tDfGXS6mmR/mmDewlZR8mmSNkb+KAw8wWxO57gru0+vAAiuAh3YHx/XzBUW1VF CgS0Sllyk+8NgMh9MIaKyb7qKNBArjNrNxKbCv4N4TwHP74Q3UKn2/Kb4A8EMn0ml0B0 tdFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WcQqBOO6; 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 gy15si18218527ejb.752.2020.12.28.06.16.21; Mon, 28 Dec 2020 06:16:46 -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=WcQqBOO6; 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 S2440383AbgL1OOS (ORCPT + 99 others); Mon, 28 Dec 2020 09:14:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:48566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440340AbgL1OOL (ORCPT ); Mon, 28 Dec 2020 09:14:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 65D68206E5; Mon, 28 Dec 2020 14:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164836; bh=zYZgqytYpVxvRNMrzkJ5uRDr3iyaoyaxFjbENdYl2IM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WcQqBOO6AKzEqxSd6nsfYbtHML4u5OXmvRpNYXw/Km86pJ1N3hgqMPRIq4UykCg+0 Ylwdrf6aVFB4Yn2wqMv0ASZuqwC5dnM1Cx9zlu0aqevjjc+w48Fn5+kZiVBkeuDOMk zhhXvtmCi2Hrjh4RobdrmHIMidecXwkv0v1WCLq4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Guenter Roeck , Sasha Levin Subject: [PATCH 5.10 275/717] hwmon: (ina3221) Fix PM usage counter unbalance in ina3221_write_enable Date: Mon, 28 Dec 2020 13:44:33 +0100 Message-Id: <20201228125034.193166117@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 bce776f10069c806290eaac712ba73432ae8ecd7 ] pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. We fix it by replacing it with pm_runtime_resume_and_get to keep usage counter balanced. It depends on the mainline commit[PM: runtime: Add pm_runtime_resume_and_get to deal with usagecounter]. Fixes: 323aeb0eb5d9a ("hwmon: (ina3221) Add PM runtime support") Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201202145320.1135614-1-zhangqilong3@huawei.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/ina3221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 41fb17e0d6416..ad11cbddc3a7b 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -489,7 +489,7 @@ static int ina3221_write_enable(struct device *dev, int channel, bool enable) /* For enabling routine, increase refcount and resume() at first */ if (enable) { - ret = pm_runtime_get_sync(ina->pm_dev); + ret = pm_runtime_resume_and_get(ina->pm_dev); if (ret < 0) { dev_err(dev, "Failed to get PM runtime\n"); return ret; -- 2.27.0