lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181221084212.GG211587@dtor-ws>
Date:   Fri, 21 Dec 2018 00:42:12 -0800
From:   Dmitry Torokhov <dmitry.torokhov@...il.com>
To:     Yangtao Li <tiny.windzz@...il.com>
Cc:     linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5] Input: i8042 add i8042_is_mr_coffee() helper to avoid
 refconut leak

On Sat, Dec 15, 2018 at 04:08:46AM -0500, Yangtao Li wrote:
> of_find_node_by_path() acquires a reference to the node returned by
> it and that reference needs to be dropped by its caller. Add
> i8042_is_mr_coffee() helper to avoid refconut leak.
> 
> Signed-off-by: Yangtao Li <tiny.windzz@...il.com>
> ---
> changes in v5:
> -fix typo

Has this at least been actually compiled by you?

> 
> changes in v4:
> -fix typo
> 
> changes in v3:
> -add i8042_is_mr_coffee
> ---
>  drivers/input/serio/i8042-sparcio.h | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
> index 796289846204..9e9e512bc432 100644
> --- a/drivers/input/serio/i8042-sparcio.h
> +++ b/drivers/input/serio/i8042-sparcio.h
> @@ -106,11 +106,23 @@ static struct platform_driver sparc_i8042_driver = {
>  	.remove		= sparc_i8042_remove,
>  };
>  
> +static inline bool i8042_is_mr_coffee(void)
> +{
> +	struct device_node *root;
> +	bool is_mr_coffee;
> +
> +	root = of_find_node_by_path("/");
> +	is_mr_coffee = !strcmp(root->name, "SUNW,JavaStation-1");
> +	of_node_put(root);
> +
> +	return is_mr_coffee;
> +}
> +
>  static int __init i8042_platform_init(void)
>  {
> -	struct device_node *root = of_find_node_by_path("/");
> +	bool match = i8042_is_mr_coffee();
>  
> -	if (!strcmp(root->name, "SUNW,JavaStation-1")) {
> +	if (match) {
>  		/* Hardcoded values for MrCoffee.  */
>  		i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
>  		kbd_iobase = ioremap(0x71300060, 8);
> @@ -138,9 +150,9 @@ static int __init i8042_platform_init(void)
>  
>  static inline void i8042_platform_exit(void)
>  {
> -	struct device_node *root = of_find_node_by_path("/");
> +	bool match = i8042_is_mr_coffee();
>  
> -	if (strcmp(root->name, "SUNW,JavaStation-1"))
> +	if (!match)
>  		platform_driver_unregister(&sparc_i8042_driver);
>  }
>  
> -- 
> 2.17.0
> 

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ