Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp788900ybt; Sat, 13 Jun 2020 23:21:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqBs/x06/ZLQUFzpe7+pfIg9zlLQ61RuwresOp0E3qz5muXDKpEPRFuGWHFOcMNkv+22oY X-Received: by 2002:a17:906:31d2:: with SMTP id f18mr19935633ejf.110.1592115675393; Sat, 13 Jun 2020 23:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592115675; cv=none; d=google.com; s=arc-20160816; b=xNB7X+l/6VxWvamV+uQs1sFvr2M3OA7BT+WF5asnqKmBycu5/EivN9nehkl6va4Svb OXBpKTG4AvPnh3gGeO2oPMz7z+50HMAQgB4GWUjc0INyKGofed8jr8bNmcI2qyyFZ8cp gwqi41WVTEN9jP7FtfTR/A6JNNV9Vh9Sm82dgSepEaQIRsw6SxCTXbHQeGM7WIR3SMlw 9e1skx7HHFhhZFlSX48qYwSOOscPBfG/NIdz2cxjQWFMs5TeCHkkvfXtkiMw2vWvVUEq JL2nYjHGZIo3fpduL093ISCjgturqj3yq3CfHROsmk39TDg03ZFlDFDROVhT3wlQyOTa PKnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=9KK+F0d4mciiuo9VaW5QFXWP2Ch9Rbbv4U0+fODdYfw=; b=UFOGGewPMPUFHm74jbwiQOHvm9DKnBR5l6LWTY6Nx8EvoWOv/8K5enYO13enkGDEHs CH+KMDwkz+wNJt4pjLNfRFvSLDXG66pUgUGHdrig/sc4qQ6fAeQKGDW7BVXjzOxUCJw6 PDDiUZ1W5fpYUSXt7/w82tmhf07sx0/HyFNVU5VZhhxOT/s1EacL+6AXQHQMskYouaY3 xFZIsygkAP81lUaoAJTU4JYrAgHKuUB5ZU0pOdAUYhGCoszzHlP0EWBjzszRvs0G5KZ2 e3+lCH91yOERnnXpw/MaW/BqBVj/vgIj2nmdrfIXbDq7ncLTkhXzFKjB9a8nHrsiCqI1 p4lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HDUWrCkg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si6745564edf.480.2020.06.13.23.20.52; Sat, 13 Jun 2020 23:21:15 -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=@gmail.com header.s=20161025 header.b=HDUWrCkg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725949AbgFNGTI (ORCPT + 99 others); Sun, 14 Jun 2020 02:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725265AbgFNGTI (ORCPT ); Sun, 14 Jun 2020 02:19:08 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E72DAC03E96F; Sat, 13 Jun 2020 23:19:07 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id h3so12425015ilh.13; Sat, 13 Jun 2020 23:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9KK+F0d4mciiuo9VaW5QFXWP2Ch9Rbbv4U0+fODdYfw=; b=HDUWrCkggu0J1UgH7dQO1nYEXZBkr5iknhM0hWr8Cxnps2IFyJvHAbm6BhL5HSHOiL WX37C60DJVxnU40AE6VWz63fnS75SQgC69ZoK7b/4wqZFHl/156yjZLfXFBhaqHKs106 KoJLVkVbIXH+4J8MHF1Z175hMrrlHTeDtn62CqD6mnQ54WNqw5M/VJREluvKXfAxAfP/ 0U+8b0JwdnROS3sjXzFelRhMmBiRdzI5LyeP2gNsQCUhskCB/SuMwoUdzPb24surrQ99 1kQ2hnm8DG3Wc39OJrUbpKTLvfNB5vzFrmr+MyV+IExRyF84+5aA59fAIPji1X7t4f2A RAaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9KK+F0d4mciiuo9VaW5QFXWP2Ch9Rbbv4U0+fODdYfw=; b=Pvskfe3YELDqtHE9AKbtoTSYEr+/8K9DF692tdR4SEZPNoqs+lJk3WJVooQO0vODBU 86HotH8N887NrM4IHzqu79f8J3P8BR0EqxrQPZJQXSY0OQsV7ToVQ9Zu7TXeJzhrV2V0 EifZTd/yA5RlPAU8W80E72WgoF4fM4XQZyh0N+wgLW7cG4KzNNvtit93t1+vL1RPU7/q Q588uZrY/TqF2DT9YfDTK03QkgtE1m6P9ZhTZwKzwlBkqB51UYUV5e1mi+m3oBPCArhi dahQL4pM3/LilL6w/Ym099Aznhq1QuWimb5JeONwZRlG269KoO5AdPuTJ5uw35E7rYbx LrPQ== X-Gm-Message-State: AOAM532ur2yKCAhgs/fH0TCx2Jlckbb3tt3qC/riiG1pPYfpVW20lvjB XX9uzX6EgyyDi2o/BwCHRTY= X-Received: by 2002:a92:d1d0:: with SMTP id u16mr20748595ilg.7.1592115547052; Sat, 13 Jun 2020 23:19:07 -0700 (PDT) Received: from cs-u-kase.dtc.umn.edu (cs-u-kase.cs.umn.edu. [160.94.64.2]) by smtp.googlemail.com with ESMTPSA id c3sm5798908ilr.45.2020.06.13.23.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 23:19:06 -0700 (PDT) From: Navid Emamdoost To: Dmitry Torokhov , Maxime Coquelin , Alexandre Torgue , Navid Emamdoost , linux-input@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: emamd001@umn.edu, wu000273@umn.edu, kjlu@umn.edu, smccaman@umn.edu Subject: [PATCH] Input: stmfts: fix ref count leak in stmfts_input_open Date: Sun, 14 Jun 2020 01:18:59 -0500 Message-Id: <20200614061900.75253-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org in stmfts_input_open, pm_runtime_get_sync is called which increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning. Signed-off-by: Navid Emamdoost --- drivers/input/touchscreen/stmfts.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c index b6f95f20f924..1ef282d7cc14 100644 --- a/drivers/input/touchscreen/stmfts.c +++ b/drivers/input/touchscreen/stmfts.c @@ -339,11 +339,11 @@ static int stmfts_input_open(struct input_dev *dev) err = pm_runtime_get_sync(&sdata->client->dev); if (err < 0) - return err; + goto out; err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON); if (err) - return err; + goto out; mutex_lock(&sdata->mutex); sdata->running = true; @@ -367,6 +367,9 @@ static int stmfts_input_open(struct input_dev *dev) } return 0; +out: + pm_runtime_put(&sdata->client->dev); + return err; } static void stmfts_input_close(struct input_dev *dev) -- 2.17.1