linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Input: synaptics-rmi4: fix possible double free
@ 2019-04-18  1:58 Pan Bian
  2019-04-19  7:39 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2019-04-18  1:58 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Wei Yongjun, Nick Dyer, Nick Desaulniers, Kees Cook, linux-input,
	linux-kernel, Pan Bian

The RMI4 function structure has been released in rmi_register_function
if error occurs. However, it will be released again in the function
rmi_create_function, which may result in a double-free bug.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/input/rmi4/rmi_driver.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index fc3ab93..7fb358f 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -860,7 +860,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,
 
 	error = rmi_register_function(fn);
 	if (error)
-		goto err_put_fn;
+		return error;
 
 	if (pdt->function_number == 0x01)
 		data->f01_container = fn;
@@ -870,10 +870,6 @@ static int rmi_create_function(struct rmi_device *rmi_dev,
 	list_add_tail(&fn->node, &data->function_list);
 
 	return RMI_SCAN_CONTINUE;
-
-err_put_fn:
-	put_device(&fn->dev);
-	return error;
 }
 
 void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake)
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Input: synaptics-rmi4: fix possible double free
  2019-04-18  1:58 Input: synaptics-rmi4: fix possible double free Pan Bian
@ 2019-04-19  7:39 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2019-04-19  7:39 UTC (permalink / raw)
  To: Pan Bian
  Cc: Wei Yongjun, Nick Dyer, Nick Desaulniers, Kees Cook, linux-input,
	linux-kernel

On Thu, Apr 18, 2019 at 09:58:35AM +0800, Pan Bian wrote:
> The RMI4 function structure has been released in rmi_register_function
> if error occurs. However, it will be released again in the function
> rmi_create_function, which may result in a double-free bug.
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>

Applied, thank you.

> ---
>  drivers/input/rmi4/rmi_driver.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index fc3ab93..7fb358f 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -860,7 +860,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,
>  
>  	error = rmi_register_function(fn);
>  	if (error)
> -		goto err_put_fn;
> +		return error;
>  
>  	if (pdt->function_number == 0x01)
>  		data->f01_container = fn;
> @@ -870,10 +870,6 @@ static int rmi_create_function(struct rmi_device *rmi_dev,
>  	list_add_tail(&fn->node, &data->function_list);
>  
>  	return RMI_SCAN_CONTINUE;
> -
> -err_put_fn:
> -	put_device(&fn->dev);
> -	return error;
>  }
>  
>  void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake)
> -- 
> 2.7.4
> 
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-19 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18  1:58 Input: synaptics-rmi4: fix possible double free Pan Bian
2019-04-19  7:39 ` Dmitry Torokhov

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).