Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp576714iog; Mon, 13 Jun 2022 08:27:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tMpWTUs5mZBA8zTC6GH8tSglDqaTltDip56ZVcVvwa5WH94b1XBt3L/4j2h4RUYc+swm0i X-Received: by 2002:aa7:d456:0:b0:42d:d7d9:34c1 with SMTP id q22-20020aa7d456000000b0042dd7d934c1mr287971edr.21.1655134031645; Mon, 13 Jun 2022 08:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134031; cv=none; d=google.com; s=arc-20160816; b=o2eT3eHvNzrGrt9BL0Ore2sSncFyOOjCo5Ye4FL4hGGJm2SOmk+R8bqGD4JBw6fAWD oRmffUioupgtQNce9xciZHWGZGxPogF0OITCocgsE0MxL0JH3oOIp9f5SnxPU92oO7rP jzwMHpHbbwgXUt4KGhH/IsjjrIy5jnLA+jGqbAGobB/5NICTAuu6xuoUFYif1+eejWeT Dp7JvzwHHp9KczBbQh77rElM+fDklK0t602lGnbSzCtVrb7E3L9/oBbtbYg3um5JVcZo HMd4xtx4kwxd9sXShgASdFCJoY+74EQD4fIqGECEMVHDznQTdHC2Mw3hZeUDdTIBFsPR VO2g== 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=Yt3HtB5/QVCk4yIMKtHCWIXDHG2wVB3b/sSgfuCbzsc=; b=AL8ZLI1+WoX7vLqOqVg5w6nzQNVqd1+q/hyEU/b0GGkYvIs5o5LJBtyIiZm/1uj5Zy SWvUS6zhX+9OhqBJoN3PtywNqt6grFBmkYR4x9K1SoC+rf/TnMRkrFD8ehM5vqSJWdGB Ft4mIaNHuBeqtEka9gZTgI+4EkKPi3jaEPdWuWT2MqTCgNr92MTf+IPKI4hNytC2a/wf JFlWv88lj9n64pV/005X9o9Bl4biknWdeoEIh+r+2JUz07La1sF01fHbb9DzyfAbCO6A LRcpeKuotKnXb9ic/zVcaNjeunu17DspwZZpXmW1eNAHbJxZl9QqWwyL2nzRkt8CEHLY JtZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zHkdwdCr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v9-20020a1709061dc900b006fee1ad5962si5987950ejh.111.2022.06.13.08.26.46; Mon, 13 Jun 2022 08:27:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zHkdwdCr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1353170AbiFMLZK (ORCPT + 99 others); Mon, 13 Jun 2022 07:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352824AbiFMLS6 (ORCPT ); Mon, 13 Jun 2022 07:18:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49E64396A3; Mon, 13 Jun 2022 03:40:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 86A7EB80EAD; Mon, 13 Jun 2022 10:40:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB13BC3411C; Mon, 13 Jun 2022 10:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116838; bh=WBZmf+CrEdtcxiZFnX4Xwx8RWqhSiu8hMOkOUC/WBWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zHkdwdCrVOmq0W9rifOKKZx5zGwS6HCETL/8oqazEO0cZFTty47PCrRK0NMBPwvj+ CGEyhn0E3ZEYFbcLJlBtZNhXFW7t21w1QSlR/kjq3krip5y04blkVXl+XZM3DHmvSU WbCZD5F5B5fDViiISn9ed11KiHuQ9tp50O7U2MvE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Machek , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.4 195/411] Input: stmfts - do not leave device disabled in stmfts_input_open Date: Mon, 13 Jun 2022 12:07:48 +0200 Message-Id: <20220613094934.509129154@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Torokhov [ Upstream commit 5f76955ab1e43e5795a9631b22ca4f918a0ae986 ] The commit 26623eea0da3 attempted to deal with potential leak of runtime PM counter when opening the touchscreen device, however it ended up erroneously dropping the counter in the case of successfully enabling the device. Let's address this by using pm_runtime_resume_and_get() and then executing pm_runtime_put_sync() only when we fail to send "sense on" command to the device. Fixes: 26623eea0da3 ("Input: stmfts - fix reference leak in stmfts_input_open") Reported-by: Pavel Machek Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/touchscreen/stmfts.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c index be1dd504d5b1..20bc2279a2f2 100644 --- a/drivers/input/touchscreen/stmfts.c +++ b/drivers/input/touchscreen/stmfts.c @@ -337,13 +337,15 @@ static int stmfts_input_open(struct input_dev *dev) struct stmfts_data *sdata = input_get_drvdata(dev); int err; - err = pm_runtime_get_sync(&sdata->client->dev); - if (err < 0) - goto out; + err = pm_runtime_resume_and_get(&sdata->client->dev); + if (err) + return err; err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON); - if (err) - goto out; + if (err) { + pm_runtime_put_sync(&sdata->client->dev); + return err; + } mutex_lock(&sdata->mutex); sdata->running = true; @@ -366,9 +368,7 @@ static int stmfts_input_open(struct input_dev *dev) "failed to enable touchkey\n"); } -out: - pm_runtime_put_noidle(&sdata->client->dev); - return err; + return 0; } static void stmfts_input_close(struct input_dev *dev) -- 2.35.1