Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp780141ybt; Sat, 13 Jun 2020 23:00:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3EnJ1lprTeAjUQ4/1ll0KNuNbvcVMvPKc97xLzdkoRqm7W+fF3/gxNyyyfOuH07y3ujIT X-Received: by 2002:a17:906:a288:: with SMTP id i8mr8019891ejz.324.1592114423199; Sat, 13 Jun 2020 23:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592114423; cv=none; d=google.com; s=arc-20160816; b=NqjDiK2SLWYB0XdHR8G9E53iTXXMoFu1Oz+Xii13fTeMtsJMvpz89FSIlrRT3t2s9q oyUGc7VQTrY4l2RxKPUBPsddwKuQX4KQSO7QTLBhlUMV5vTf0sDT8qm/fcig2Kap97wB DI7Owrrc/OStDh5o+mzvv1K2GXWoGc3UMD/eTsDEnDzoynqDJjJPaVpCa9FMV5LMeLuK ysoyVf7CQrWnOLaTDgW6rQ6VrrlXsuFcX+TXUBe3V1r5DuRF2GcYhITuWLvrsD4pS0cj lpsN0Po1eFM7T10gI9bDrB6tzqbn4T63qBeDREJc7mCeoVimKnpcPo2KU0EI9V9kH3Ej dRFA== 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=HWTtSELZk3B/c/eLDXpjAtutg42doyiLctGP7zQlm7s=; b=XGbj4ZVjIw+s/hI1IoXOjTFpyK+z1G1VsP/lPUF4uFEWJ2dXcsyaZB4s25o8JcGSJv m7oYUH3MbUGVmyAHo2FxU//7i55sAHYTbOOFN+vtkFIorBDyz1jxFQbVgKE6V++fhICR OjfOiyOIaDuFZ3G8GvrpRkb/rNY9n1s0+0K4DFf9MnRDiL3BVlniMrJhjr11klUx7L3g vSuEnYbXPxLqtdkA3xnpG3Iy8+GIScNQzU8OEwdhCKJgSsbkIaKxqRaRuO+57QhdaJ7N TBeVvl7G2bOvahzoQmt+9j6fU18lSd0l9tbFghdamgcOylHCooxUmLMgo3tyOG9TL/5Q nC+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c5ldnigW; 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.00.00; Sat, 13 Jun 2020 23:00:23 -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=c5ldnigW; 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 S1726679AbgFNF4L (ORCPT + 99 others); Sun, 14 Jun 2020 01:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgFNF4L (ORCPT ); Sun, 14 Jun 2020 01:56:11 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B11C03E96F; Sat, 13 Jun 2020 22:56:11 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id m81so14486600ioa.1; Sat, 13 Jun 2020 22:56:11 -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=HWTtSELZk3B/c/eLDXpjAtutg42doyiLctGP7zQlm7s=; b=c5ldnigWSGlAw/OZqVtWDPs1Vf/pl/8HaFmEyJl3Zntwky/chEpqbU5TlTIuCW/vV2 mkIagLfJ9rwOSQ90odu0i9e7YN8VnKnLXayD2LXCADQr6t8IiaNHLqnyvVgfEUUUWwM7 3+B9x2oabcOgsv3/TsZV80QjRfBuc8fo7wUohWPwNn/peIIQIbXQbr5aV/HRK4eY1yU8 gcD2OILCb4EikF8Yci6NP0fGk5uLPnLMw5cCmEGNDJqMQ+XQOt9q3wizw2FMFJlho+OI M0XtdBafxNfdeY4riaD7YiKdhuCRk5yqn1OukBWHVRHSKBvSY/G5fg1yJnYwUxa1orEY nIOg== 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=HWTtSELZk3B/c/eLDXpjAtutg42doyiLctGP7zQlm7s=; b=eg0mabyfgIgB0CkMUvzP4SlmtTWUMw65WCIy/UJveTsSWPI4yf3eQUOiuEwbwspMtZ V2caTXgC4LVJDzvy6Nh8Yjh6N5acThETmPQm8ZmR/NYG/nM4zWR3U7XimChZCJ+ASFpY n+SCi3ahilc0b0I0upab+1OAVWL7PlHo9hLGj61kjgFUEWcUlFAjQRZP4o47OBvcqWsA +eoCwEh9rE2hl4WaWjbF8sf4jm/ZvkPejEve1Q2kz0oZ6F1p9pJEscmY4F4mdefxo5w0 yYPr+WPnGIOQ5ZNNFdFUgGgT5aJks2Q3yzcZQCi4wopqvL/5N02Wo7jZTUF3CF2vXYBI NeeA== X-Gm-Message-State: AOAM531+brKCznCm0Wv/9WQxQ305FVAqvL5ErZW4udEx6rEPTwUXaf9p XBVP5NZNCGmozsWCSss77tsfmwRCT+8= X-Received: by 2002:a5e:c706:: with SMTP id f6mr21586067iop.186.1592114170290; Sat, 13 Jun 2020 22:56:10 -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 r17sm5916359ilc.33.2020.06.13.22.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 22:56:09 -0700 (PDT) From: Navid Emamdoost To: Dmitry Torokhov , Navid Emamdoost , Jonathan Bakker , =?UTF-8?q?Pawe=C5=82=20Chmiel?= , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: emamd001@umn.edu, wu000273@umn.edu, kjlu@umn.edu, smccaman@umn.edu Subject: [PATCH] Input: bma150: fix ref count leak in bma150_open Date: Sun, 14 Jun 2020 00:56:02 -0500 Message-Id: <20200614055604.67969-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 bma150_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/misc/bma150.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c index a9d984da95f3..e2f1b05fcb2a 100644 --- a/drivers/input/misc/bma150.c +++ b/drivers/input/misc/bma150.c @@ -348,7 +348,7 @@ static int bma150_open(struct input_dev *input) error = pm_runtime_get_sync(&bma150->client->dev); if (error < 0 && error != -ENOSYS) - return error; + goto out; /* * See if runtime PM woke up the device. If runtime PM @@ -357,10 +357,13 @@ static int bma150_open(struct input_dev *input) if (bma150->mode != BMA150_MODE_NORMAL) { error = bma150_set_mode(bma150, BMA150_MODE_NORMAL); if (error) - return error; + goto out; } return 0; +out: + pm_runtime_put(&bma150->client->dev); + return error; } static void bma150_close(struct input_dev *input) -- 2.17.1