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: <20200221093251.GA90355@kroah.com>
Date:   Fri, 21 Feb 2020 10:32:51 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Jiri Slaby <jslaby@...e.cz>
Cc:     linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/9] vt: selection, remove 2 local variables from
 set_selection_kernel

On Wed, Feb 19, 2020 at 08:39:45AM +0100, Jiri Slaby wrote:
> multiplier and mode are not actually needed:
> * multiplier is used only in kmalloc_array, so use "use_unicode ? 4 : 1"
>   directly
> * mode is used only to assign a bool in this manner:
>   if (cond)
>     x = true;
>   else
>     x = false;
>   So do "x = cond" directly.
> 
> Signed-off-by: Jiri Slaby <jslaby@...e.cz>
> ---
>  drivers/tty/vt/selection.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
> index 714992693974..6541c09d8bba 100644
> --- a/drivers/tty/vt/selection.c
> +++ b/drivers/tty/vt/selection.c
> @@ -191,9 +191,9 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
>  	struct vc_data *vc = vc_cons[fg_console].d;
>  	int new_sel_start, new_sel_end, spc;
>  	char *bp, *obp;
> -	int i, ps, pe, multiplier;
> +	int i, ps, pe;
>  	u32 c;
> -	int mode, ret = 0;
> +	int ret = 0;
>  
>  	poke_blanked_console();
>  
> @@ -224,11 +224,7 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
>  		clear_selection();
>  		sel_cons = vc_cons[fg_console].d;
>  	}
> -	mode = vt_do_kdgkbmode(fg_console);
> -	if (mode == K_UNICODE)
> -		use_unicode = 1;
> -	else
> -		use_unicode = 0;
> +	use_unicode = vt_do_kdgkbmode(fg_console) == K_UNICODE;
>  
>  	switch (v->sel_mode)
>  	{
> @@ -312,8 +308,8 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
>  	sel_end = new_sel_end;
>  
>  	/* Allocate a new buffer before freeing the old one ... */
> -	multiplier = use_unicode ? 4 : 1;  /* chars can take up to 4 bytes */
> -	bp = kmalloc_array((sel_end - sel_start) / 2 + 1, multiplier,
> +	/* chars can take up to 4 bytes with unicode */
> +	bp = kmalloc_array((sel_end - sel_start) / 2 + 1, use_unicode ? 4 : 1,
>  			   GFP_KERNEL);
>  	if (!bp) {
>  		printk(KERN_WARNING "selection: kmalloc() failed\n");
> -- 
> 2.25.0
> 

This patch fails to apply to my tree, so I stopped here.  Can you rebase
and resend the rest of these?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ