Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2170727iof; Tue, 7 Jun 2022 22:05:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEwgAbsGrN9z7YYINRPsk7wtHyj0xOdMOy54E9YPZkpNBecHFZYHl/kDrCGmGc5X2+Qzy3 X-Received: by 2002:a05:6a00:15c6:b0:51c:61bb:a62d with SMTP id o6-20020a056a0015c600b0051c61bba62dmr2047333pfu.30.1654664729367; Tue, 07 Jun 2022 22:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654664729; cv=none; d=google.com; s=arc-20160816; b=kSxJfgyHwJDW1abawF6iJoInGh4wsIMaooLtGZ8YuI6mNxnpp254XlpPSGwZ7f/nIG NWARM5WtARnJbes4Hsr1gukANSoHyeWYjosP8hsFSIW5jTQKG0Lj//kpS9/je7xkOGQ3 OkUuMa/nA17mYpdYI1qMWIeKNat06mSESH6NNCMR9fS7Zq09btrJx7BQlNc5cbGUhYE+ Nhbi8UH7ODuYfbiyjIK4SRLjep8vfYmfXXdl2c9S1rkW5Swmg0y9FMaRSukFTAOS5iMu KN0CYcJcIKLkd3P1U4EpSs5mME9HGXcHMmC32Qvk9VWsoqh+PKU8zfSTGVRPjTcxBbF+ pgrw== 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=EDbWnCghj0OmR08w9apH4QXmWjqq0MORY4BUPKqrtLY=; b=bfKYx1tQ7LyoP+n3c2hRD+5IAVkPZmIXTha2FZmmHv3EVGSTALGtoHekvApmBaTXpo 5R1lProrw+U2HFxfi+a6luxNgFybR47Mo/a+e3bM1HynKIh1bijDtYAZ+pSTxeVjrEpx Cjx5H9o4Q9ssg2mihLx17+hnmikiAtfeIJfq7lU7WxV4nM5GHZVPTOhK/4LbRCaPTLpj OzUgsxghbOcy2zV2vR+B7oJbzRrlbZKqpn+/IbWSbjcGC3jom9KgupLRy8yOywJWABcW eE0LoSUzHs48LoEyvhQLtY/X6htYQ4CEK9KGbwNxzNEwGy7+9Px1jNs535ypt890IT+l VGkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MELragdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a14-20020a17090abe0e00b001e3015b93absi23899770pjs.12.2022.06.07.22.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:05:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MELragdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 52967463F6A; Tue, 7 Jun 2022 21:33:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349010AbiFGRzZ (ORCPT + 99 others); Tue, 7 Jun 2022 13:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348686AbiFGRgk (ORCPT ); Tue, 7 Jun 2022 13:36:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40B241145C; Tue, 7 Jun 2022 10:33:03 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 66352614B5; Tue, 7 Jun 2022 17:32:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7899DC34119; Tue, 7 Jun 2022 17:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623163; bh=tmYD8/nsll7NJKmVEHlF3A1b8W1FaCtSrxRU7QBuKKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MELragdlSxVByOX+qI2YOR/hqhjTYfcmOG1NMF6sy5xkZg0aDhBHLyna/HDuaezWI Fjdj3/6sV4/p/PChtU4aTwdX+Y00pRbugibOmADsk9uT0NBTiN6XjhdpCTbZJwijpt GB3dbDMglWa1/MDS8DCfwwfSo0sq1qXP7ButIP4Y= 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.10 317/452] Input: stmfts - do not leave device disabled in stmfts_input_open Date: Tue, 7 Jun 2022 19:02:54 +0200 Message-Id: <20220607164918.004714780@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 64b690a72d10..a05a7a66b4ed 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