Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp343790pxf; Thu, 8 Apr 2021 04:28:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywxlOU2MCzZbUA+EpqeYRjacxBOe9In1gILxllD7qbCc3IgFLArfnqg0nXZLiU+29jhw5O X-Received: by 2002:a05:6402:4245:: with SMTP id g5mr10770156edb.306.1617881293450; Thu, 08 Apr 2021 04:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617881293; cv=none; d=google.com; s=arc-20160816; b=SqCMZHYDA0Mc4SvnH3v71O3CX530+UGfvGRJdD2geDiL6fgbL2Wd6NKYlOZBAuzGkz sfb5qs3mLsRhaDznipADTuiydUy2NCpC+08eIXgd10Qkz3ZrDLhYoXiKaFJLxCjhcZRm XQGutyripJVXcYS3qlN0ti+e/bRiA3C/a2d3CggHSDl3LlSfVbWAGID24I8l2CFP/8IL K1eqh2ZZHf8jcqxSk44PmMiFUwaLk3+fQw+5qcyWav0gu63dEpJbEMPjcB8FmhA2x4CY +74NvOygJ5lRF8GMISaYqEMZ9IBhVmpOSq5dcJYcGN3MAgEoW1qULJP13L8+EBP2SZzV Kz5A== 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=wJ/liccSD7G88ahiQWxc8sVLc93x/jWTyyWTjtVpUPY=; b=frhthgDrTYHQK9kDrL3dyJ2YJFwIJU7n9qL6IhptlMSnbUbyxUMR5dRJy6z++uAvtM rac6h7U7Aiiq7a9UAqFanGNj/XLvHslBqjB45MpmzNg6h/LAm6/j2gxCd9KRf17p8ej3 ctmJJ895fREZw+6O3/q85CCGhRyuTF6UPAlVBTFGg8H0ySat4MMw+2eYxcWXMw3vx5DF dIjSuz3VTWscRRinCcLrNrkAzwTUildJAxtpWYriF4VKAj/5QDEetcB71ehG8JNVg6hx prqS2U5SYJ2XonQd2LvyVCHRyLUl/G4mz9vLWKjO/omWaZ5Zf5CEG/3OzityGGAOnYDi TVOg== 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 t15si13637172edd.446.2021.04.08.04.27.50; Thu, 08 Apr 2021 04:28:13 -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 S231259AbhDHLZG (ORCPT + 99 others); Thu, 8 Apr 2021 07:25:06 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:15972 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbhDHLZE (ORCPT ); Thu, 8 Apr 2021 07:25:04 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FGJlN63q1zrdJ2; Thu, 8 Apr 2021 19:22:40 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.98) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 19:24:43 +0800 From: Pu Lehui To: CC: , , , , , Subject: [PATCH -next] i2c: img-scb: fix PM reference leak in img_i2c_xfer() Date: Thu, 8 Apr 2021 19:24:48 +0800 Message-ID: <20210408112448.211380-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-img-scb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c index 98a89301ed2a..8e987945ed45 100644 --- a/drivers/i2c/busses/i2c-img-scb.c +++ b/drivers/i2c/busses/i2c-img-scb.c @@ -1057,7 +1057,7 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, atomic = true; } - ret = pm_runtime_get_sync(adap->dev.parent); + ret = pm_runtime_resume_and_get(adap->dev.parent); if (ret < 0) return ret; @@ -1158,7 +1158,7 @@ static int img_i2c_init(struct img_i2c *i2c) u32 rev; int ret; - ret = pm_runtime_get_sync(i2c->adap.dev.parent); + ret = pm_runtime_resume_and_get(i2c->adap.dev.parent); if (ret < 0) return ret; -- 2.17.1