Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp345657pxf; Thu, 8 Apr 2021 04:30:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3XMhMRZQN7G120b6C+rs2jVdeiWiiE1aSR/Vj8Dn8d/yo+/ksI5QXtEf7VzoNxo3b0QS9 X-Received: by 2002:a17:906:3950:: with SMTP id g16mr9768927eje.116.1617881447922; Thu, 08 Apr 2021 04:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617881447; cv=none; d=google.com; s=arc-20160816; b=wykCGXBQjO2VSwnIs10hhA8vSw2rj9IAufZcgrmDeZnsGMjQ3gSsmLXYOh7gWwj+mr 9AFl5mbXezck5l5ozZJSoLXaPC7uFqgj6TIsI59O2WjwMZ3EMMkyOJU1/V4+jLCqCoib Tv/DZeAJtrEASD3HThMkGKQKbBHEN23NiodWMKZBT8/FKbeLrf1gr5ipEhCzFhUe496s dGAXQyAFf/UaSLci82+oQEsGWBSpGTIKSbOIdaM5bBFMZgRLaBTjBtIqf86ij1hQLnNC Nxt5on8+wy1ee7N8pB2eA7tlDosPuBsP1uC3n/ZQrypNygx/DwhXdFwFTKNvPkFipKA2 ynRA== 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=GCWwguHw+d2eBbr/HSvPbwNRqJLlfRcUgJWWzJn0vq7jBmYRoIIvxzjZhoqV9PYO5V JAtlEcmSHOTuQpIUAxp4eTD7D8OkKa4qSuSZtPcuf2uHBTY1XvEz2oM3NORllJqiFpND aje+ZxrG0uN4qW8PsF/HdIr9aOh64WLJ8YNXVKlzoC8mBagTLa3lRkT0FrHWAQIRsnll BD7gAMILoaflz5SawAWGK/0Yag+zjIO1aOsawtIltRoWdnBadW9qkhd4HD0EWy8P/e0O rZSmnWP0sB1mPuXBej/w5hI8iuOPA+fzylsGRwgt2Y6xZzN5PN7KFZL8TYu7/FBeGTJa yRQw== 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 h16si22735762edv.460.2021.04.08.04.30.24; Thu, 08 Apr 2021 04:30:47 -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 S231163AbhDHL30 (ORCPT + 99 others); Thu, 8 Apr 2021 07:29:26 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16094 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230411AbhDHL3Z (ORCPT ); Thu, 8 Apr 2021 07:29:25 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FGJrP48krz19L3J; Thu, 8 Apr 2021 19:27:01 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.98) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 19:29:06 +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:29:10 +0800 Message-ID: <20210408112910.212873-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