Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4624173pxj; Wed, 12 May 2021 09:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKkBBIU28PrijITy2YaqLIeBqI7BanJVVckaG/5yrHwVi0DKcjQQfuFe97nzcjukgtgOWQ X-Received: by 2002:aa7:d146:: with SMTP id r6mr45091667edo.344.1620836924131; 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=KyZr8GNUrbA0SCT1eXQdCtSVeRjsjWqaA/kk6b6CyvTv9UAq7410DW8yKYhdwUbjUi Irc5feLsCms1w2+JJrmGEvdvF/Bs7fsvtDqXhAHX5dgfvw8p4wLQgFkHHXM7BcnpXBe3 WYEFLATEE7hMaIjEukrLxS8zthbpAUloDCuWere54jbcwGWDqNC7cjP+mXJW01QIld5t XaamgqKnlP9MCucH/F4g1CaWpZ8FKh6u5jPRkEPCFT/BM4OVbgXeEuc5HJxOKCfU6bbM iC3+fpKbJfC5Zu6anjw+FXuIonssZv05Ir5mZ7Zx5gQ+RIYGI7aJSUCeJiVStGwCJTSb Xg7A== 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=JV0Rre7q9xzZvdxjri/vnbSnIIzmv56h3o3X+A5SiMc=; b=dEMp//xeK2o3PKG0HT/oHKXSKA1HkLQiRdIKsEQWvlPuPmECXNwaQyB9KuaqG/qAXD FeRnBB+d7LQ1bCgZM7gVl1Q3C+snkDV4yMjUerML0woSiwx75wb2vLAcaIx0MP7HKF71 +cpswVnBs4MarcsAIHmwnY84nDexnYroQYf8ltsTxuYKVAmSAD957z4IRe7azVSio1Gs ZMBfov8WoyZ2+8CnuUdlN4SzdAWBtAi7npeVdrGO2OehNQkT8mirIy6Ci8Ao17IXNPVh jp4VVlw9xBeoyJdr8E8jcmxMHmIeV6n5NviQQOaGsRiap5y7J8z6ubv/bGcKpZHeoZqJ SU2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dt/vF+2J"; 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 ay17si456493ejb.340.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="dt/vF+2J"; 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 S241664AbhELQ1r (ORCPT + 99 others); Wed, 12 May 2021 12:27:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:54422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbhELPiU (ORCPT ); Wed, 12 May 2021 11:38:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0108F61447; Wed, 12 May 2021 15:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832807; bh=stNhE00ZYP3qm9u/BggeMLPbWctUcAJiQGGVcCR5dX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dt/vF+2JrAjChRtW47PW2P3yNsrmWeaD83n/rKQ7T59aEYL2gp+IrQ4HIJtuVjVtP HWAanvB7JZtuKzukdHvuH00qUCHNVrk/5hnxEEz+RARN+7cp96kYxDFkVFFn00cWtr eTuCpEsXhWtqPZfSdyNJbQ+MbwEvE9u1zQIMcGs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Qinglang Miao , Oleksij Rempel , Wolfram Sang , Sasha Levin Subject: [PATCH 5.10 431/530] i2c: imx: fix reference leak when pm_runtime_get_sync fails Date: Wed, 12 May 2021 16:49:01 +0200 Message-Id: <20210512144833.931768671@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 47ff617217ca6a13194fcb35c6c3a0c57c080693 ] In i2c_imx_xfer() and i2c_imx_remove(), the pm reference count is not expected to be incremented on return. However, pm_runtime_get_sync will increment 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: 3a5ee18d2a32 ("i2c: imx: implement master_xfer_atomic callback") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Reviewed-by: Oleksij Rempel Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index e6f8d6e45a15..72af4b4d1318 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -1036,7 +1036,7 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, struct imx_i2c_struct *i2c_imx = i2c_get_adapdata(adapter); int result; - result = pm_runtime_get_sync(i2c_imx->adapter.dev.parent); + result = pm_runtime_resume_and_get(i2c_imx->adapter.dev.parent); if (result < 0) return result; @@ -1280,7 +1280,7 @@ static int i2c_imx_remove(struct platform_device *pdev) struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev); int irq, ret; - ret = pm_runtime_get_sync(&pdev->dev); + ret = pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) return ret; -- 2.30.2