Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4623844pxj; Wed, 12 May 2021 09:28:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPuz7A8/Ct3HRhuKEjg0iSyufv+5mmkA8yO0S7iPfQuNjcu794Y5+ptHSHb0SasVlePEsv X-Received: by 2002:a05:6808:54d:: with SMTP id i13mr27125706oig.100.1620836897312; Wed, 12 May 2021 09:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836897; cv=none; d=google.com; s=arc-20160816; b=DjoPui2wvmvwh/X74KYcsqOy3v0tKAOxqFbsGESUcisLgSS4HTQ4FyM2UkbT6JEM+N TsLSI1LD0YGZeUgA8SXw3iqaXB+7tjV+z0ARlQrBg9jOir1ykbt8hks910omxz889ywA DfDq1J4ykAi+hkVOLqy3op97rEAW/D+4u4+aY9fL65RxopkC6KPwylBVNPnTwCljV3db oK2jfrH1VWn5JgqhMJcc2kqdPd5L+CnOg+ggfz7FDVDcpxDpJ37lxxP13m7Cms3xCgLl mOWnXgruUFbIa704hRO2IKlMLOvA3p46Ic2zZPdz0WghDZiVQjJjASYCjDDqZJJMZio3 eR+g== 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=8I75k1nm7ypjMfVDhIXqOk/3viil2VBgx3WJVuQc2BQ=; b=atwg08U/oY/7JNBEBNmI1PdH5rCMSqJzt+TTtndOt3pIL+L85Af3gFPlkZfJwWsLJX +nQM/PhgSNnpHChOOGmch/aSSyOTULQN767cc7p+R95R1/NefcA9O3niMERdAcD1SC91 iZlF78ctSfLQrOA59kC/isnMJZz6BufZ2stj7PXf5N3MDh6M8dibaAmUnqeUYTIGeJ7X GWuJkkMJsi6yPZJAy8iWA4Ya0cy2njHi04DOKd4nI4fCzWE6y/HRPezxTT7pZ2JmNqvx occ2KFcaGxVZQn4+eRqJOpW/OHyAzDGlZhBPqRLNMQtphwXkWRUcB2Oa5ymA6pQrBz3W iBUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qi4Bb9fh; 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 j24si355033otq.26.2021.05.12.09.28.03; Wed, 12 May 2021 09:28:17 -0700 (PDT) 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=Qi4Bb9fh; 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 S231665AbhELQ2G (ORCPT + 99 others); Wed, 12 May 2021 12:28:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:57044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231708AbhELPiU (ORCPT ); Wed, 12 May 2021 11:38:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7779C61C63; Wed, 12 May 2021 15:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832820; bh=qcijQx95h+lRm0cz4YZ4JFo08J43H8yQ6iqo2AaYK0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qi4Bb9fhdL11Xv/sILl84nlO36bTvSB9XElqv7N033fafaM6ZGucpM4D42oiRQyBx 85m0JbBXZscZWJXvBaHytHaTi0aBqHdm/Qwsx3D+DYl5OeeEgz7CRRyBCh97h2Cz/Q fwDMtcJ3rOCPMw6tQTmBOXQcdpxc9hfRPDOGBM70= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Qinglang Miao , Wolfram Sang , Sasha Levin Subject: [PATCH 5.10 435/530] i2c: xiic: fix reference leak when pm_runtime_get_sync fails Date: Wed, 12 May 2021 16:49:05 +0200 Message-Id: <20210512144834.056410047@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Qinglang Miao [ Upstream commit a85c5c7a3aa8041777ff691400b4046e56149fd3 ] The PM reference count is not expected to be incremented on return in xiic_xfer and xiic_i2c_remove. However, pm_runtime_get_sync will increment the PM reference count even failed. Forgetting to putting operation will result in a reference leak here. Replace it with pm_runtime_resume_and_get to keep usage counter balanced. Fixes: 10b17004a74c ("i2c: xiic: Fix the clocking across bind unbind") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-xiic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 087b2951942e..2a8568b97c14 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -706,7 +706,7 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) dev_dbg(adap->dev.parent, "%s entry SR: 0x%x\n", __func__, xiic_getreg8(i2c, XIIC_SR_REG_OFFSET)); - err = pm_runtime_get_sync(i2c->dev); + err = pm_runtime_resume_and_get(i2c->dev); if (err < 0) return err; @@ -873,7 +873,7 @@ static int xiic_i2c_remove(struct platform_device *pdev) /* remove adapter & data */ i2c_del_adapter(&i2c->adap); - ret = pm_runtime_get_sync(i2c->dev); + ret = pm_runtime_resume_and_get(i2c->dev); if (ret < 0) return ret; -- 2.30.2