Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp341809pxf; Thu, 8 Apr 2021 04:25:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/dV3i+MkTCerEL543tCcvvm/yrYW1psyeaFCE629DjkoTPH7+nivZWDLOVjzLMv7+DnIZ X-Received: by 2002:a17:902:dacd:b029:e5:cf71:3901 with SMTP id q13-20020a170902dacdb02900e5cf713901mr7067622plx.23.1617881107235; Thu, 08 Apr 2021 04:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617881107; cv=none; d=google.com; s=arc-20160816; b=LbAvRTAlqKXTwrf6mBMtuqcPGOmww+8uJkmJXmW4Aj7lEVp3SPSaHVMrHJCJmF6kuT 4zHMmkJK24wk9fnGupy83DDtwWRarolOTFcYIZcGiltivW0x8rVkjFxP4XOg5Sl8KOns 3juFRKGpz/iK9tOIRZ4Dq0WIF4/y8ZxGjYElruNj3p8FbrTYfQPQ2o64vL3fLrmmJFYn E2bPQBj/h03L1dxkUg4kTo9kDtyTuxx51rjoahPYUD+MbS06RTd5d3nMevxTSn5x143Q dKIFOTZHigTHhzF1+1Na6QUFeF3fS7mefH3Hi2EEGebryWCsPk/UDKfmoEUCwfjbU8qI 8xOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=VPMJCj3saC/YPTKpsLDNtJ+1yuk2bDrZ3w3sNnN3CLw=; b=l+GgvZfwReXEe16b8JrVBjplf7Kh9yArRmsH+rCL8a5WA1aJuTUN47YY+yNeiKSYHV 4IPJEfSZZlQNdlAYfPOaUM1U3eu3XF23rmFdGCLgGGXsGJO7Vtm3nxQgl9mGXuevlSn2 lwpyNLM9328/vCZN9E/r/GMJoOHZMT4TQx6okDCQi9GOgFbOWhG3UI7Tp6+j6WvsXU2s /pT1HVUl+UyIVUzFaZFi3/XZREfWJGeVitNAm8KFDBPLfwiVlBNNprUVCLvobbcQC+r4 uOIuFA74uKl14vfVJrcrQHITB9E+8OXRJruMWnRGd5hIHOl2xh0wTDElwV0jx4zkV2ru RbuA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l1si27769951plt.82.2021.04.08.04.24.54; Thu, 08 Apr 2021 04:25:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230467AbhDHLYM (ORCPT + 99 others); Thu, 8 Apr 2021 07:24:12 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16093 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231132AbhDHLYK (ORCPT ); Thu, 8 Apr 2021 07:24:10 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FGJkL2ypYz19KtW; Thu, 8 Apr 2021 19:21:46 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.98) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 19:23:48 +0800 From: Pu Lehui To: CC: , , , , , Subject: [PATCH -next] i2c: cadence: Fix PM reference leak in cdns_i2c_master_xfer() Date: Thu, 8 Apr 2021 19:23:52 +0800 Message-ID: <20210408112352.211173-1-pulehui@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.98] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pm_runtime_get_sync() will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. Fix it by replacing it with pm_runtime_resume_and_get() to keep usage counter balanced. Signed-off-by: Pu Lehui --- 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.17.1