From: Navid Emamdoost <navid.emamdoost@gmail.com>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Navid Emamdoost" <navid.emamdoost@gmail.com>,
"Jonathan Bakker" <xc-racer2@live.ca>,
"Paweł Chmiel" <pawel.mikolaj.chmiel@gmail.com>,
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 [thread overview]
Message-ID: <20200614055604.67969-1-navid.emamdoost@gmail.com> (raw)
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 <navid.emamdoost@gmail.com>
---
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
next reply other threads:[~2020-06-14 5:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-14 5:56 Navid Emamdoost [this message]
2020-06-14 9:27 ` [PATCH] Input: bma150: fix ref count leak in bma150_open Andy Shevchenko
2020-06-15 6:35 ` [PATCH v2] " Navid Emamdoost
2020-06-15 6:36 ` [PATCH] " Navid Emamdoost
-- strict thread matches above, loose matches on Subject: below --
2020-06-14 9:17 Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200614055604.67969-1-navid.emamdoost@gmail.com \
--to=navid.emamdoost@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=emamd001@umn.edu \
--cc=kjlu@umn.edu \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pawel.mikolaj.chmiel@gmail.com \
--cc=smccaman@umn.edu \
--cc=wu000273@umn.edu \
--cc=xc-racer2@live.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).