>From 0338a89a873e7df57707852402f90bb0d6626f12 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee 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 Reported-by: Yue Haibing Fixes: 221bcb24c653 ("Input: walkera0701 - use parallel port device model") Cc: stable@vger.kernel.org # v4.4+ Signed-off-by: Sudip Mukherjee --- 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