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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180531114437.GA11598@kroah.com>
Date:   Thu, 31 May 2018 13:44:37 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Yisheng Xie <xieyisheng1@...wei.com>
Cc:     linux-kernel@...r.kernel.org, andy.shevchenko@...il.com,
        Quytelda Kahja <quytelda@...alin.org>,
        devel@...verdev.osuosl.org
Subject: Re: [PATCH v2 03/21] Staging: gdm724x: use match_string() helper

On Thu, May 31, 2018 at 07:11:08PM +0800, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used instead of open coded variant.
> 
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: Quytelda Kahja <quytelda@...alin.org>
> Cc: devel@...verdev.osuosl.org
> Signed-off-by: Yisheng Xie <xieyisheng1@...wei.com>
> ---
> v2:
>  - const DRIVER_STRING instead  - per Andy
> 
>  drivers/staging/gdm724x/gdm_tty.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index 3cdebb8..397ecaa 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -43,7 +43,7 @@
>  static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
>  static DEFINE_MUTEX(gdm_table_lock);
>  
> -static char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"};
> +static const char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"};
>  static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"};
>  
>  static void gdm_port_destruct(struct tty_port *port)
> @@ -65,22 +65,14 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
>  {
>  	struct gdm *gdm = NULL;
>  	int ret;
> -	int i;
> -	int j;
> -
> -	j = GDM_TTY_MINOR;
> -	for (i = 0; i < TTY_MAX_COUNT; i++) {
> -		if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) {
> -			j = tty->index;
> -			break;
> -		}
> -	}
>  
> -	if (j == GDM_TTY_MINOR)
> +	ret = match_string(DRIVER_STRING, TTY_MAX_COUNT,
> +			   tty->driver->driver_name);
> +	if (ret < 0 || tty->index == GDM_TTY_MINOR)
>  		return -ENODEV;

Very odd rewrite here.  Why call this function if you think the initial
parameters are not correct?  Are you sure about your test for
tty->index?

This should be cleaned up more please.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ