Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1582661ybk; Thu, 21 May 2020 10:12:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqQpTJsHzLkS7MQdKSqSmAKtkoHwfnHKm/42jfeNEKIh1fEsxlqzcw/oLS88k9ZNeZ4oYa X-Received: by 2002:a17:906:6a43:: with SMTP id n3mr4338995ejs.33.1590081124979; Thu, 21 May 2020 10:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590081124; cv=none; d=google.com; s=arc-20160816; b=i+vwDVTZ43Tn4gaqyyN4Q105q3S+RkDIE5gpr9TkHTlJl7rDvKtYR7VCllHWJjqJBH 2gxNTFaNMVjp8V7kVQpx1HCcnzucW1peAhxiVoDDfj6amSdONl3Vh05BqtyN0AU2OcTm Ayg/3kvqaiekMiStVEZeUldapdRfft6/hqpyeF3NPWI+moKDGP2/Feufi9wh2pqp+Jct VU+5/D2VVfY8XfYXQyMWiU2vahDt0GrfE26QtsH04NfobC3DmEIiv667EZ0z9ry7uj81 G8cXGbTL//6GZ1bKW9dUMAryS+/64754MNmB+9z9L/R7TqdEZsxrhwO7u+zdMgkSAM9g KEtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=FK1zS2xI4nCWnSpbxzgQ2+nHuV663avTL49uxq6F1OQ=; b=ERokJoBs6Q3b5PVxSIOIWjIkOJs/cK4Qi8BkkrEguMStK7LSePuxnx/vE/9np3yRfK e3jNPfWu5co3w7mFbKnukveonVuXb/Mx/pC+vvcR+FuD68KFigf9a+6Dd/udHNChq9SN PCBEkHFkjWrzxzCTjhnA/ykSy2lQqthFSza7X33Qkp7LhfA3R8gqNyJv0tsIsDb6rElo rh9gJAK0+07vZcy2FkgtPm8z41udNTbbn5diWuCfSVboveWtCEXC8JUhMligxlkRXVdg uDO9PgyTi3ERKukt8CRPr9QLWbXk+0kg3IlLkq9q8ylc76SWDrbqggk85zdlQTtRdCr0 s5OQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si3274253edz.400.2020.05.21.10.11.41; Thu, 21 May 2020 10:12:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729997AbgEURIN (ORCPT + 99 others); Thu, 21 May 2020 13:08:13 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:48578 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728565AbgEURIM (ORCPT ); Thu, 21 May 2020 13:08:12 -0400 Received: from 89-64-86-91.dynamic.chello.pl (89.64.86.91) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id bed6dafa262e0ef4; Thu, 21 May 2020 19:08:10 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Marek Szyprowski , Ulf Hansson , Krzysztof Kozlowski , Michael Turquette Subject: [PATCH] PM: runtime: clk: Fix clk_pm_runtime_get() error path Date: Thu, 21 May 2020 19:08:09 +0200 Message-ID: <5127441.yGvM1JjtLk@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki clk_pm_runtime_get() assumes that the PM-runtime usage counter will be dropped by pm_runtime_get_sync() on errors, which is not the case, so PM-runtime references to devices acquired by the former are leaked on errors returned by the latter. Fix this by modifying clk_pm_runtime_get() to drop the reference if pm_runtime_get_sync() returns an error. Fixes: 9a34b45397e5 clk: Add support for runtime PM Cc: 4.15+ # 4.15+ Signed-off-by: Rafael J. Wysocki --- drivers/clk/clk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) Index: linux-pm/drivers/clk/clk.c =================================================================== --- linux-pm.orig/drivers/clk/clk.c +++ linux-pm/drivers/clk/clk.c @@ -114,7 +114,11 @@ static int clk_pm_runtime_get(struct clk return 0; ret = pm_runtime_get_sync(core->dev); - return ret < 0 ? ret : 0; + if (ret < 0) { + pm_runtime_put_noidle(core->dev); + return ret; + } + return 0; } static void clk_pm_runtime_put(struct clk_core *core)