Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4627125pxj; Wed, 12 May 2021 09:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9LpjmMP42O4xFPQQ874mGW9myWGS3jiYzcY8bKBQoIGRriU4245JsyVqzHzJfGPYzXG8H X-Received: by 2002:a2e:8899:: with SMTP id k25mr29054617lji.449.1620837142638; Wed, 12 May 2021 09:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837142; cv=none; d=google.com; s=arc-20160816; b=zD+xmDQ0Il8s6eyOgUcix29Dl+JuHCUlGJb8ElGfUmm3aQNo7HLH7fJuAijqUMGwj0 T4fweMrTDIt4OAwaf75EjVuZh+pCaSMi5x4Ca/PpMrwkCOK4pC08wWHG52hD9O6O9YPC jhHTfN42q7YjPi6zKi7fYhaSk9dIKfRZUQ1UfhU2uFwX/GMGoShgsS5+U7wbzIz+9QYd tI0liEM4XgxMrCR9kJYd3hq9N1qlkqJgSZNcB5oDh+IBwabLMr8+PQsm5E0zmSUihH1V 05IF+bGJNaF6SjCdESmy7gO9rZGa+HJ7+/6byEmXpIx/maJwQA90c4R8m0eGnxa3eZrt 9B6w== 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=JrDCu/gNifDSXb8SEos+tux8AYtLT2Pwl3rxnRhONlg=; b=N7/95rQctei7cUbj3ve6csOzbvsyFoCo4FE59lZSnRGAJ8HaMOaqLrXLr4Edvwtq7h euby+zB+spacmVT9woQiwoJmFbed/FXIEHoX8tbSuKjwTMok6Q0IgSmdAO7K3YMcu97z XyMHYvRKFizrSi65v367t8jq5I8u7lt0jnKq9ee/5FW14KVtEE0e1Zhe6+EEnfuPq8iN oeUoW5tnBZXFr03NroiYpKgJkWV5yQ3g8sf0+2LaC2+NLczX2jDh6e480e5liBLY+lmJ UAAXIUbaUI9dWHo2FrhjwW7NPzVWPn5QiiWzuXTdVT3wZkLoiVdy/tcihM57aA7BKiSu 0qZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P7WVge+2; 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 y34si238766lje.589.2021.05.12.09.31.52; Wed, 12 May 2021 09:32:22 -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=P7WVge+2; 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 S241511AbhELQ11 (ORCPT + 99 others); Wed, 12 May 2021 12:27:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:56688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbhELPiF (ORCPT ); Wed, 12 May 2021 11:38:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF6FF61C6B; Wed, 12 May 2021 15:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832800; bh=wHGr8/2MKJ9QkujvqJp8NVpSdB7CSZyNxCnj1lOrdvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P7WVge+2FtGO9JfyPJr3MsGgGPXiobaG46gt0f7eRdp8zTq9PD2OAb6ZvJ6UReCc/ g2zYz0/LclQhFzIVvvc1nf78Chehu4WvA5yN734lcAy+kFjM4XhqnWG8apPX63cqzH y/cz/lga7UtHT/Tq6lclb7CU8ye5XBj9bMYXkytE= 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 428/530] i2c: cadence: fix reference leak when pm_runtime_get_sync fails Date: Wed, 12 May 2021 16:48:58 +0200 Message-Id: <20210512144833.836367447@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 23ceb8462dc6f4b4decdb5536a7e5fc477cdf0b6 ] The PM reference count is not expected to be incremented on return in functions cdns_i2c_master_xfer and cdns_reg_slave. However, pm_runtime_get_sync will increment pm usage counter 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: 7fa32329ca03 ("i2c: cadence: Move to sensible power management") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-cadence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index e4b7f2a951ad..e8eae8725900 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -789,7 +789,7 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, bool change_role = false; #endif - ret = pm_runtime_get_sync(id->dev); + ret = pm_runtime_resume_and_get(id->dev); if (ret < 0) return ret; @@ -911,7 +911,7 @@ static int cdns_reg_slave(struct i2c_client *slave) if (slave->flags & I2C_CLIENT_TEN) return -EAFNOSUPPORT; - ret = pm_runtime_get_sync(id->dev); + ret = pm_runtime_resume_and_get(id->dev); if (ret < 0) return ret; -- 2.30.2