Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4624177pxj; Wed, 12 May 2021 09:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOvWu8pzNJ0VWf0t99QbisRoMTqHxFbqjADZGl1eGJtpcRhe/gH9fLQrDGq3BVq8z01laA X-Received: by 2002:a05:6402:1643:: with SMTP id s3mr43304497edx.280.1620836924132; Wed, 12 May 2021 09:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836924; cv=none; d=google.com; s=arc-20160816; b=SZffXfBxIjztMSMGwNhOPc1X6jYVwndRMK72SKg6UGiRUDowoUaZ6/UfNLP3KchP2V 5f8RsexUYn8zURHUMnr1InQU6iTTiz9KbS2HtfrUnVx8sSkvvux4F7dsppN+jyP+qm6U Npo1qAgCofsUT5OpvvQraNA0OEC5wDEZr7/+EPxvXNdMObg3NXGnU7TTYlPGBC6ctzDq hEp2hJlW/ueK7qJ0SILzvVgAxn9EOlMcRcXIoO3frqvsN4pdVdOlB7ImlWNKoBSLmfD1 r/L8Ofmau5vosE+A1KC5SUnSfmfO5qfH1ricbtTiRjYNRMilG0YNis+eUyaWiTeMkcM0 VK7Q== 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=a06d6mfU03PzhxDKqio4pJ1H0tzJAQd08d6WQha47T8=; b=oKbBgvn/gVkbUkyMDqC4lzSJ2YOhjKksHymUk0P3h1dFZN8WGz/2I9/rpvfffzrmVn OKDBmAiJ5R3Cha9P1f8YG8yiU5ua4/aMu/LY5G2fZ1fu0iE566QvxWf5w0Y4lkderoxJ Pr2NKgKj7Fff2Xey8L3gl86SOfUvvSyh8j8ver/ZK1G8W/wU9z+JFpOAeSMCp4VTKXBl Fs9Axy4J1Yn8t3rZj3pR0iu1TlDASlX+fZclQWmWBTH/QvPyWWScLgsvYtH8vmpbdU6T OH/117fy21PTOdlBbKfQqd8QFP5miaA8z/Y0LTSBdM4vNqvYI1hMiuL5cTkX/sCGBSi3 gLlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RvwOtzuc; 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 dd6si413045ejb.639.2021.05.12.09.28.19; Wed, 12 May 2021 09:28:44 -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=RvwOtzuc; 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 S241601AbhELQ1h (ORCPT + 99 others); Wed, 12 May 2021 12:27:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbhELPiP (ORCPT ); Wed, 12 May 2021 11:38:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91F52619A8; Wed, 12 May 2021 15:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832805; bh=Sz9w2m3rG2JmL0SoYcKXy+7G7vWIenZoaa1Z7dv16r4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RvwOtzucuckTh1uBxb8Oq+fjQXWyiEPp1nSoRiAp/O8+5fUTnbxqKZrRI2lC1LpIK TfPn6nld3/rJNHkyBGXDELnVvEE/ujidxe1sTGsC2Yi2TaigT8I6wsuqSqwgvodaum i1Irnzenc6l0zBu0ja7IrKqmRE3iyxgZEHANL24Q= 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 430/530] i2c: imx-lpi2c: fix reference leak when pm_runtime_get_sync fails Date: Wed, 12 May 2021 16:49:00 +0200 Message-Id: <20210512144833.900533348@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 278e5bbdb9a94fa063c0f9bcde2479d0b8042462 ] The PM reference count is not expected to be incremented on return in lpi2c_imx_master_enable. 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: 13d6eb20fc79 ("i2c: imx-lpi2c: add runtime pm support") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-imx-lpi2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 9db6ccded5e9..8b9ba055c418 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -259,7 +259,7 @@ static int lpi2c_imx_master_enable(struct lpi2c_imx_struct *lpi2c_imx) unsigned int temp; int ret; - ret = pm_runtime_get_sync(lpi2c_imx->adapter.dev.parent); + ret = pm_runtime_resume_and_get(lpi2c_imx->adapter.dev.parent); if (ret < 0) return ret; -- 2.30.2