Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4567952pxj; Wed, 12 May 2021 08:21:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztQiGMbpvljsJuGg3RAZNWYNKPS1BmiVTQO4+s5W9VE7CHLjViPjYUI2CkvwBJobn55ELH X-Received: by 2002:aa7:d801:: with SMTP id v1mr44568425edq.349.1620832867319; Wed, 12 May 2021 08:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620832867; cv=none; d=google.com; s=arc-20160816; b=Pk4x9BOPIGhY/FOMMkUzvBnds4LutmFsGzV7CauYlhAjSTpPsd8IMZBdN/i/w/mtYS pIfiUpz3+O0bPoFsqb65yGvmMPb7fX0NMKx5hl4ohXa9Vqjy+WSqupgiqKi5AOjaLQng VVf8v9v/i/HM2UnRBQd3nhQy2+lat6pq2VajAj2Hw/gIkt5kLEFmSAWYsji8nOOb8Orm 4zYqqtD+6f9PQCRLcyqRkacP4xgkES9AYL3iZpZd44vrz9bjFDXSvxEaMGduVcUHLoRN bhgB8ERzba2rHdBlHGA/V97YjudLyJ9zru0ZhoKjGRYcqohtCv5FYFR0aXNJh1IdhyA9 SfzA== 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=hThgmE8eqQtNG+6a+0fZw+hO3WzhDrjkV9lr3olA7FM=; b=eP5A/z46bCbFvOT+t6NNnYvGav8YAgCZNBPJ+9P26T2+y5O9V4D1GkgKO0DQooygCG NrElzPFtK4CcR3nllZ+xDZLqGgX2ouybydJ24vptxpWipvWHvImorqGF7t38UN7wdDR0 4IewXG+uiHscjMGFeSCZmVijGxdtcjvopepCsHRqMCFQldhFk8TZc7Lo7igTTIz+h59J Xs0YFf9eEtIV4NhCNNK0N5kPHJ3xgYbT5kcQkZ7rtSnfBN1LTsMMIBh4yG/NrXdFSCwp 6tMM7JL52CFS3LoWrdLOBjQarvK8Jgod8J1WLoF5BwK2ZDsczOoDzYRVkOv5jtJZWXM6 Y0PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ra6/gg5+"; 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 n8si3573edy.554.2021.05.12.08.20.43; Wed, 12 May 2021 08:21: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ra6/gg5+"; 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 S233501AbhELPS0 (ORCPT + 99 others); Wed, 12 May 2021 11:18:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:41650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233337AbhELPId (ORCPT ); Wed, 12 May 2021 11:08:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D25A61960; Wed, 12 May 2021 15:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831718; bh=UdQtrS5unoNSQ6uobhqjA6gIpjhxRlfnPPHA8oU/I+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ra6/gg5+8zYqIe9UZgVk9xbwtWxssUie+/AAA4hFiFgQ517+qF0+/Y8/eqXJXl3ML vUG/4e0N5gR9NjQ+/A9fNYrpZBWcdqoAMZuQx5yJ2k3POIFix6UuqCrTuNzhCVPvp2 ThC90kWwICPy/0HbRfAiJFJSwU6G6GpyO0Vqfgd4= 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.4 197/244] i2c: img-scb: fix reference leak when pm_runtime_get_sync fails Date: Wed, 12 May 2021 16:49:28 +0200 Message-Id: <20210512144749.299593454@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144743.039977287@linuxfoundation.org> References: <20210512144743.039977287@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 223125e37af8a641ea4a09747a6a52172fc4b903 ] The PM reference count is not expected to be incremented on return in functions img_i2c_xfer and img_i2c_init. 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: 93222bd9b966 ("i2c: img-scb: Add runtime PM") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- 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 20a4fbc53007..a1f8a9a91213 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.30.2