From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Yue Haibing <yuehaibing@huawei.com>
Cc: dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org,
linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: walkera0701 - Fix possible NULL pointer dereference in walkera0701_detach
Date: Wed, 16 Oct 2019 16:29:14 +0100 [thread overview]
Message-ID: <20191016152914.ubzaluipboeku5zz@debian> (raw)
In-Reply-To: <20190423145637.35004-1-yuehaibing@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 637 bytes --]
On Tue, Apr 23, 2019 at 10:56:37PM +0800, Yue Haibing wrote:
> From: YueHaibing <yuehaibing@huawei.com>
>
> KASAN report this:
<snip>
>
> static void walkera0701_detach(struct parport *port)
> {
> struct walkera_dev *w = &w_dev;
>
> - if (!w->pardevice || w->parport->number != port->number)
> + if (!w->parport)
It doesn't look correct. This way the detach function will never know the
port number to which it is attached, and as a result it will try to do
detach() with all the ports in the system.
Please check the attached patch and maybe (if possible) ask Hulk Robot
to verify if it fixes the problem.
--
Regards
Sudip
[-- Attachment #2: 0001-Input-walkera0701-Fix-possible-NULL-pointer-derefere.patch --]
[-- Type: text/x-diff, Size: 1406 bytes --]
From 0338a89a873e7df57707852402f90bb0d6626f12 Mon Sep 17 00:00:00 2001
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Date: Wed, 16 Oct 2019 16:08:43 +0100
Subject: [PATCH] Input: walkera0701 - Fix possible NULL pointer dereference
If walkera0701_attach() fails and input_dev is made NULL then we are
unregistering the pardevice but it still has the pointer to the dev
which has now been released. And as a result in the walkera0701_detach()
it will now try to do input_unregister_device() with a NULL pointer.
We should mark the pardevice as NULL when it is unregistered.
Reported-by: Hulk Robot <hulkci@huawei.com>
Reported-by: Yue Haibing <yuehaibing@huawei.com>
Fixes: 221bcb24c653 ("Input: walkera0701 - use parallel port device model")
Cc: stable@vger.kernel.org # v4.4+
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
drivers/input/joystick/walkera0701.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c
index 56abc8c6c763..d8ae1329bf00 100644
--- a/drivers/input/joystick/walkera0701.c
+++ b/drivers/input/joystick/walkera0701.c
@@ -275,6 +275,7 @@ static void walkera0701_attach(struct parport *pp)
input_free_device(w->input_dev);
err_unregister_device:
parport_unregister_device(w->pardevice);
+ w->pardevice = NULL;
}
static void walkera0701_detach(struct parport *port)
--
2.11.0
prev parent reply other threads:[~2019-10-16 15:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-23 14:56 [PATCH] Input: walkera0701 - Fix possible NULL pointer dereference in walkera0701_detach Yue Haibing
2019-05-17 2:38 ` YueHaibing
2019-10-16 15:29 ` Sudip Mukherjee [this message]
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=20191016152914.ubzaluipboeku5zz@debian \
--to=sudipm.mukherjee@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yuehaibing@huawei.com \
/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