Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9120139pxu; Mon, 28 Dec 2020 07:07:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzY+uLdZIF5A2QhZx/5cNLP05lwloc8x4I4aUEe29hZITqU5dznxaPd66K1atdwgInf8TXv X-Received: by 2002:a17:907:214d:: with SMTP id rk13mr43058877ejb.501.1609168077421; Mon, 28 Dec 2020 07:07:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609168077; cv=none; d=google.com; s=arc-20160816; b=c6iloH41SxyDHAdIuSEAUslQAA5u8TrDH97eo3CNc6YLHJxiaq4SSbi3QeGl7qtSLg gvpiFh2wHamirXCuqHrOXXtEFmg/rmxL09sDOKOV2/iiCXtp1lKTkeN4l+Lx012BfENq ozIxmu4uaJrxrat9qvGe3AX+Zp/srB3m3UiopeHzFtX7v+D+I09W9tpxVSKD6wV2oV5K 1kmSnHpk3R4BacfoUoDVNZ6IIK5hYPg9U2VX43hy7lmz/tKTvmHV2sxgJclY4evS/UpA 9Z+qt4nVQTUQCDZElV+pa1cHMYxXz0fAlX4k7hQH+MTm+vyjwXH+SzeuGr9q3gPhlm64 1kwQ== 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=o92Bh/nhIJDB2UofmyVZw3a73TpHqFzoNA9NXmgdAvI=; b=Ce4vBYg04l2AFx602pabxI87FJlWru7MCcrisrrSfSQAZFr71Fw6GhCCaj53MW3IiA ADy4tSTf/UwOZyV8KCjY3IhWpPv2TV6n/SKKVEePj42TaLiZsVrQ4RjmEIxu7BuywuXb eINtNTuBPJLdReRc64N/SaQ9pF2TbA9S3op7+wjN/svK+gwkvSxtz0ujZrprmYvbeoQh d2mTyiYpdBsnPHg2eAdvbuTlB/B0ZDBprpdgwh9WMb/VCWDmilGDs4lB+hRWCq/iJlxX 02dLaBJf/QEDdhves+KS6AvLP/kHJHPsJUp09YduG4jlLqIH4rfjTkTgeHr3ds4bJrzh sRsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xEPZjLH8; 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 x13si19478515ejb.243.2020.12.28.07.07.33; Mon, 28 Dec 2020 07:07:57 -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=xEPZjLH8; 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 S2439539AbgL1PFc (ORCPT + 99 others); Mon, 28 Dec 2020 10:05:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:45278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439092AbgL1OKn (ORCPT ); Mon, 28 Dec 2020 09:10:43 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0C23207A9; Mon, 28 Dec 2020 14:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164602; bh=/H0URN6vjAXxVFYXc2J8OtP/uXBDLqmC5M9Wr3X1s7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xEPZjLH840Fs3xVefnn0sI2GDtsv+7wpEpZ1mZEooFfu90MFrHeNLYuWCOdNSBZJt VbiDUcMNmYq1245UzvbnM4wQO75yC9fdSf7T1//GaXjWSjsb3qzo7jTKcpbmxNli4A 0YdbBNqnYXIe1gQfyuOvN+KFrIontKZK+0DmbTVI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.10 232/717] power: supply: bq24190_charger: fix reference leak Date: Mon, 28 Dec 2020 13:43:50 +0100 Message-Id: <20201228125032.103817478@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 b2f6cb78eaa1cad57dd3fe11d0458cd4fae9a584 ] pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to call pm_runtime_put_noidle will result in reference leak in callers(bq24190_sysfs_show, bq24190_charger_get_property, bq24190_charger_set_property, bq24190_battery_get_property, bq24190_battery_set_property), so we should fix it. Fixes: f385e6e2a1532 ("power: bq24190_charger: Use PM runtime autosuspend") Signed-off-by: Zhang Qilong Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/bq24190_charger.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index d14186525e1e9..845af0f44c022 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -448,8 +448,10 @@ static ssize_t bq24190_sysfs_show(struct device *dev, return -EINVAL; ret = pm_runtime_get_sync(bdi->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(bdi->dev); return ret; + } ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v); if (ret) @@ -1077,8 +1079,10 @@ static int bq24190_charger_get_property(struct power_supply *psy, dev_dbg(bdi->dev, "prop: %d\n", psp); ret = pm_runtime_get_sync(bdi->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(bdi->dev); return ret; + } switch (psp) { case POWER_SUPPLY_PROP_CHARGE_TYPE: @@ -1149,8 +1153,10 @@ static int bq24190_charger_set_property(struct power_supply *psy, dev_dbg(bdi->dev, "prop: %d\n", psp); ret = pm_runtime_get_sync(bdi->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(bdi->dev); return ret; + } switch (psp) { case POWER_SUPPLY_PROP_ONLINE: @@ -1410,8 +1416,10 @@ static int bq24190_battery_get_property(struct power_supply *psy, dev_dbg(bdi->dev, "prop: %d\n", psp); ret = pm_runtime_get_sync(bdi->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(bdi->dev); return ret; + } switch (psp) { case POWER_SUPPLY_PROP_STATUS: @@ -1456,8 +1464,10 @@ static int bq24190_battery_set_property(struct power_supply *psy, dev_dbg(bdi->dev, "prop: %d\n", psp); ret = pm_runtime_get_sync(bdi->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(bdi->dev); return ret; + } switch (psp) { case POWER_SUPPLY_PROP_ONLINE: -- 2.27.0