Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4626831pxj; Wed, 12 May 2021 09:32:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxweaddLmC8Q3WxMszbIgOI5UZMlcAFb00dILiIX1kqz2HuBw0q/lTumZz/3x4j4P20EVHO X-Received: by 2002:a05:6830:51:: with SMTP id d17mr16901684otp.75.1620837120800; Wed, 12 May 2021 09:32:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837120; cv=none; d=google.com; s=arc-20160816; b=t4JuVsHgRFsQ32lpTB4UIo30wOx1sRE9xrR/9V3FHZdbRbmVR6mBSNu2DQeXVJSLgR bMMNbJk2if/UPv0U23qptlG5V4M90CIpV1Nufbd0aC8x0qhQ/aWNdlidhn+Ybfazpfa1 3k0YZOQiMlW4beGFG1kOnRg/8u01ezplM5ElUD2wldjCkNrREv7y1+Y+NQQuhNIhDP3/ jZ4Wd+xNebwRQk5tCPDWCQ61tSgxomjzUB9skfGXKA+3o3oiOV8jOgodl/XQ71xc9Cy9 n/V2TVhWGhovyN4MFTJ4YN4a6gjNgTSnLiA7N5WLkfkv2KQQLknBdnPQZ1bYUfuyB251 n02A== 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=PodBaWTBleYNl/TSKA+rWBIK0LHWBGoad0ecCVkWLLk=; b=Kn1Ma2vQ05taou3pTbPOAQlBmTsRkhWaEAVidZJA9Xw5zcQ7BwHXqHElK+SiGOyVRu lh6S8Y3LrHoINyB5UTLGhp1+MPNEZCTynVvyocwJtcc/1t3qwRpJik6bXcfo0o5ggrj0 8/ukIYlqhq8gz1WRNAp+sQ/RrtDJ6dWq57CEGyLrwr1jTNL7nXUwg6LizqlHz3zfI4S3 0BvxLSIomlGHCVAhYl9F2ruDleTy2gjJUeNhBchDuZbTMjEv9Ip3C7SoT9jf3Eu09vgT TIiombcni4tz/TmMKu3JwflNLOEmYe5cO+tnpNJHwvPxpIOhfsumNV70RcIZcsvfxgQ4 uonA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=axC9+yQs; 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 u72si360223oif.179.2021.05.12.09.31.45; Wed, 12 May 2021 09:32:00 -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=axC9+yQs; 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 S241578AbhELQ1g (ORCPT + 99 others); Wed, 12 May 2021 12:27:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:56710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230407AbhELPiF (ORCPT ); Wed, 12 May 2021 11:38:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30B0761C64; Wed, 12 May 2021 15:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832802; bh=fU/4kerB8Rqj+WMxsvLlAsgQQomxfRsmta0+ohO1Heg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=axC9+yQsk2zwTLaFc3wkURrfLNy8AoYhoYpdB5LEwiYj09G1bRhu5tte2pb9Mp3HB FVKcX7x9N7r0iaKT+PTNIXQ2oDVYYMx9kBHJJQcGwEJRngpg6GK0z4WQOaVsnST+AN poEukpulR9J4+Qr3sTEejqwE1BpyuobLbphvAmLQ= 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 429/530] i2c: img-scb: fix reference leak when pm_runtime_get_sync fails Date: Wed, 12 May 2021 16:48:59 +0200 Message-Id: <20210512144833.868297954@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 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 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.30.2