Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4626913pxj; Wed, 12 May 2021 09:32:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJrO07c8KNMI+JKnhiHiy/p5QsEQ3wxjVFqONSaCkti7+9miVFyvA55rAfGekZW0BGkJav X-Received: by 2002:a1c:1bc6:: with SMTP id b189mr9015165wmb.185.1620837128235; Wed, 12 May 2021 09:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837128; cv=none; d=google.com; s=arc-20160816; b=w5+Ss6BXjJJ/6mAdFDMxktUitflJ7oDwvANHF3O4s+p6erdMFGornktvyRL6gOLWLQ Ysr+4c6eHPIC8d0aL3WYXKC7ARQYJKnSOYECLT8akXYg9UKH6qAE2HJjcH7ONW4UIrIr 0R1LchwwGHomQY5tp/8bXnMm5RmRUEOpwXqzjBVKlNeCnulmvzViEtVY0S63IAVwhxju LbU3xnNieCOJSRaKWc2j8tw5ulzLcahUyi2LVQafIrngTOoAoXCDec1ADYlaBbUPE9Lv iY902/FXx7Z4OYUVhDacTDOCa+kwbm1KSNycyOTl9SfP0WZI4sj8ePcZ9V8AwAcpgzGP /2xQ== 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=+kQ1EFfWfmBSOh7yNkxYTdxBMCRtM95cacvlvw1BCAw=; b=xsxeE4HgCcQfkKclPjkRkExWBt4jBrEq6HeBMQEvT0/zhd6N0zkIMFkWAbySdMsXTv JRjL2m0386dnujNilYvWanWETx/9616LQ762nN4eJCGDotvnbaXpWLyDQfJSnsdM0E0Z hG2Hi96YlIKnJku04Pt2MRIiCd/62EYkwjqsyjiKxpeywdPobAUCztUCY6AdljmjQNsM 1/Svg4haQs/GfsVETl4NIC9Yi2n+rks0nf7tOZj15NJqYYJMwv1sZauX0VZCqQ1Hq8KJ 556Ei6FgnusXHpjGBjsm3/zIc+AB6oo6Xm/alO40gensnAleazpi4SZpdNd+5my2LWGV lxOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U6zWfWQZ; 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 v2si136228edc.531.2021.05.12.09.31.42; Wed, 12 May 2021 09:32:08 -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=U6zWfWQZ; 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 S241630AbhELQ1j (ORCPT + 99 others); Wed, 12 May 2021 12:27:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:54482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbhELPiR (ORCPT ); Wed, 12 May 2021 11:38:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 41CDE61C66; Wed, 12 May 2021 15:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832814; bh=nQlHBUX5/jCp0UAoG7yPgYiMvTxBOCk5/kHY3pxDLPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6zWfWQZyYrUrHCw2L5X9+RfTWD/WZuqBg6eBz+vX0oQBZU30q/UEd7Hss7oKhNUx IS9UvKPTolz2VGjaemJMZZxqc7NfS2/6rdnsRdRB+3yvMbjnV+zF44BH23Ra1tZeFQ amw+Q7AQ+pYFdACR5T+/73GVV5NOpK5g3Dmt7Fxc= 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 433/530] i2c: sprd: fix reference leak when pm_runtime_get_sync fails Date: Wed, 12 May 2021 16:49:03 +0200 Message-Id: <20210512144833.994744964@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 3a4f326463117cee3adcb72999ca34a9aaafda93 ] The PM reference count is not expected to be incremented on return in sprd_i2c_master_xfer() and sprd_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: 8b9ec0719834 ("i2c: Add Spreadtrum I2C controller driver") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-sprd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c index 2917fecf6c80..8ead7e021008 100644 --- a/drivers/i2c/busses/i2c-sprd.c +++ b/drivers/i2c/busses/i2c-sprd.c @@ -290,7 +290,7 @@ static int sprd_i2c_master_xfer(struct i2c_adapter *i2c_adap, struct sprd_i2c *i2c_dev = i2c_adap->algo_data; int im, ret; - ret = pm_runtime_get_sync(i2c_dev->dev); + ret = pm_runtime_resume_and_get(i2c_dev->dev); if (ret < 0) return ret; @@ -576,7 +576,7 @@ static int sprd_i2c_remove(struct platform_device *pdev) struct sprd_i2c *i2c_dev = platform_get_drvdata(pdev); int ret; - ret = pm_runtime_get_sync(i2c_dev->dev); + ret = pm_runtime_resume_and_get(i2c_dev->dev); if (ret < 0) return ret; -- 2.30.2