From patchwork Fri Apr 14 02:10:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 673275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35E2CC77B61 for ; Fri, 14 Apr 2023 02:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbjDNCKf (ORCPT ); Thu, 13 Apr 2023 22:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjDNCKd (ORCPT ); Thu, 13 Apr 2023 22:10:33 -0400 Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2855D4EE7 for ; Thu, 13 Apr 2023 19:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=S3giKPZigRuTFiX3FzI7sBaXFQd9G5Kio3JWhJ3R0vI=; b=IriTMC+mvZvdgZcg/V36XWk/NM PNxvTImoEkXUEQotoKr3gFir977fmzv8E30z0QNRZ1sJX0Sxyep9WGF8v4J7fEmZRS8S7kkc3xVrW KVeb6gqn4y+QofB383yd0/dWKt+fV/zu6jy2DwkFvpP4Mp+zo9Uw3PdTEXgKgnLhwTHtg1zzZTtmX Knu1XDYbJQCdNA5aCPj1+vGD8r6S8ljr4qNK6dY/MHlSJn+vH6rpKdunic46fr8BOq1usXJhH69Tl wlnaFfrgqhAxs56Q0K4+UE0ueOb1mbIKem1DRp6yOroSXsFIzTuiwUMettLxFB+0vv7d/t7A3UzK6 /KXlq6+w==; Received: from sslproxy05.your-server.de ([78.46.172.2]) by www381.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pn8tS-0001SF-Em; Fri, 14 Apr 2023 04:10:30 +0200 Received: from [136.25.87.181] (helo=lars-desktop.lan) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pn8tS-000U2N-00; Fri, 14 Apr 2023 04:10:30 +0200 From: Lars-Peter Clausen To: Wolfram Sang Cc: Michal Simek , Shubhrajyoti Datta , linux-i2c@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 2/2] i2c: xiic: xiic_xfer(): Fix runtime PM leak on error path Date: Thu, 13 Apr 2023 19:10:22 -0700 Message-Id: <20230414021022.505291-2-lars@metafoo.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230414021022.505291-1-lars@metafoo.de> References: <20230414021022.505291-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26874/Thu Apr 13 09:30:39 2023) Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The xiic_xfer() function gets a runtime PM reference when the function is entered. This reference is released when the function is exited. There is currently one error path where the function exits directly, which leads to a leak of the runtime PM reference. Make sure that this error path also releases the runtime PM reference. Fixes: fdacc3c7405d ("i2c: xiic: Switch from waitqueue to completion") Signed-off-by: Lars-Peter Clausen --- drivers/i2c/busses/i2c-xiic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index e7d37eb20f2b..8a3d9817cb41 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -1164,7 +1164,7 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) err = xiic_start_xfer(i2c, msgs, num); if (err < 0) { dev_err(adap->dev.parent, "Error xiic_start_xfer\n"); - return err; + goto out; } err = wait_for_completion_timeout(&i2c->completion, XIIC_XFER_TIMEOUT); @@ -1178,6 +1178,8 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) err = (i2c->state == STATE_DONE) ? num : -EIO; } mutex_unlock(&i2c->lock); + +out: pm_runtime_mark_last_busy(i2c->dev); pm_runtime_put_autosuspend(i2c->dev); return err;