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] [day] [month] [year] [list]
Message-ID: <2024092245-theorize-griminess-4101@gregkh>
Date: Sun, 22 Sep 2024 16:56:17 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: amin-amani <didi1364@...il.com>
Cc: johan@...nel.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: serial: digi_acceleport: Improve readability and
 enhance error handling

On Sun, Sep 22, 2024 at 02:47:01PM +0330, amin-amani wrote:
> From: "A.Amani" <didi1364@...il.com>
> 
> - Improved coding style to adhere to kernel standards as suggested by
>   checkpatch.pl.
> - Indented case statements for baud rate and word size to improve code
>   readability.
> - Separated null checks for port, serial, and private data for clearer
>   error handling.
> - Improved error messages to better indicate which specific data (port,
>   serial, or private) is null.
> - No functional changes, only structural improvements and clearer
>   debugging output.
> 
> Signed-off-by: A.Amani <didi1364@...il.com>
> ---
>  drivers/usb/serial/digi_acceleport.c | 105 +++++++++++++++++++--------
>  1 file changed, 73 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
> index d1dea3850576..da707967a0c4 100644
> --- a/drivers/usb/serial/digi_acceleport.c
> +++ b/drivers/usb/serial/digi_acceleport.c
> @@ -685,25 +685,44 @@ static void digi_set_termios(struct tty_struct *tty,
>  		}
>  		switch (baud) {
>  		/* drop DTR and RTS on transition to B0 */
> -		case 0: digi_set_modem_signals(port, 0, 1); break;
> -		case 50: arg = DIGI_BAUD_50; break;
> -		case 75: arg = DIGI_BAUD_75; break;
> -		case 110: arg = DIGI_BAUD_110; break;
> -		case 150: arg = DIGI_BAUD_150; break;
> -		case 200: arg = DIGI_BAUD_200; break;
> -		case 300: arg = DIGI_BAUD_300; break;
> -		case 600: arg = DIGI_BAUD_600; break;
> -		case 1200: arg = DIGI_BAUD_1200; break;
> -		case 1800: arg = DIGI_BAUD_1800; break;
> -		case 2400: arg = DIGI_BAUD_2400; break;
> -		case 4800: arg = DIGI_BAUD_4800; break;
> -		case 9600: arg = DIGI_BAUD_9600; break;
> -		case 19200: arg = DIGI_BAUD_19200; break;
> -		case 38400: arg = DIGI_BAUD_38400; break;
> -		case 57600: arg = DIGI_BAUD_57600; break;
> -		case 115200: arg = DIGI_BAUD_115200; break;
> -		case 230400: arg = DIGI_BAUD_230400; break;
> -		case 460800: arg = DIGI_BAUD_460800; break;
> +		case 0:
> +			digi_set_modem_signals(port, 0, 1); break;
> +		case 50:
> +			arg = DIGI_BAUD_50; break;
> +		case 75:
> +			arg = DIGI_BAUD_75; break;
> +		case 110:
> +			arg = DIGI_BAUD_110; break;
> +		case 150:
> +			arg = DIGI_BAUD_150; break;
> +		case 200:
> +			arg = DIGI_BAUD_200; break;
> +		case 300:
> +			arg = DIGI_BAUD_300; break;
> +		case 600:
> +			arg = DIGI_BAUD_600; break;
> +		case 1200:
> +			arg = DIGI_BAUD_1200; break;
> +		case 1800:
> +			arg = DIGI_BAUD_1800; break;
> +		case 2400:
> +			arg = DIGI_BAUD_2400; break;
> +		case 4800:
> +			arg = DIGI_BAUD_4800; break;
> +		case 9600:
> +			arg = DIGI_BAUD_9600; break;
> +		case 19200:
> +			arg = DIGI_BAUD_19200; break;
> +		case 38400:
> +			arg = DIGI_BAUD_38400; break;
> +		case 57600:
> +			arg = DIGI_BAUD_57600; break;
> +		case 115200:
> +			arg = DIGI_BAUD_115200; break;
> +		case 230400:
> +			arg = DIGI_BAUD_230400; break;
> +		case 460800:
> +			arg = DIGI_BAUD_460800; break;
>  		default:
>  			arg = DIGI_BAUD_9600;
>  			baud = 9600;
> @@ -737,10 +756,14 @@ static void digi_set_termios(struct tty_struct *tty,
>  	if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
>  		arg = -1;
>  		switch (cflag & CSIZE) {
> -		case CS5: arg = DIGI_WORD_SIZE_5; break;
> -		case CS6: arg = DIGI_WORD_SIZE_6; break;
> -		case CS7: arg = DIGI_WORD_SIZE_7; break;
> -		case CS8: arg = DIGI_WORD_SIZE_8; break;
> +		case CS5:
> +			arg = DIGI_WORD_SIZE_5; break;
> +		case CS6:
> +			arg = DIGI_WORD_SIZE_6; break;
> +		case CS7:
> +			arg = DIGI_WORD_SIZE_7; break;
> +		case CS8:
> +			arg = DIGI_WORD_SIZE_8; break;
>  		default:
>  			dev_dbg(dev,
>  				"digi_set_termios: can't handle word size %d\n",
> @@ -967,16 +990,30 @@ static void digi_write_bulk_callback(struct urb *urb)
>  	int status = urb->status;
>  	bool wakeup;
>  
> -	/* port and serial sanity check */
> -	if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
> -		pr_err("%s: port or port->private is NULL, status=%d\n",
> +	/* port sanity check */
> +	if (port == NULL) {
> +		pr_err("%s: port is NULL, status=%d\n",
> +			__func__, status);
> +		return;
> +	}
> +	/* serial sanity check */
> +	priv = usb_get_serial_port_data(port);
> +	if (priv == NULL) {
> +		pr_err("%s: port->private is NULL, status=%d\n",
>  			__func__, status);
>  		return;
>  	}
>  	serial = port->serial;
> -	if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) {
> +	if (serial == NULL) {
>  		dev_err(&port->dev,
> -			"%s: serial or serial->private is NULL, status=%d\n",
> +			"%s: serial  is NULL, status=%d\n",
> +			__func__, status);
> +		return;
> +	}
> +	serial_priv = usb_get_serial_data(serial);
> +	if (serial_priv == NULL) {
> +		dev_err(&port->dev,
> +			"%s: serial->private is NULL, status=%d\n",
>  			__func__, status);
>  		return;
>  	}
> @@ -1309,13 +1346,17 @@ static void digi_read_bulk_callback(struct urb *urb)
>  			__func__, status);
>  		return;
>  	}
> -	if (port->serial == NULL ||
> -		(serial_priv = usb_get_serial_data(port->serial)) == NULL) {
> -		dev_err(&port->dev, "%s: serial is bad or serial->private "
> +	if (port->serial == NULL) {
> +		dev_err(&port->dev, "%s: serial is bad,"
> +			" status=%d\n", __func__, status);
> +		return;
> +	}
> +	serial_priv = usb_get_serial_data(port->serial);
> +	if (serial_priv == NULL) {
> +		dev_err(&port->dev, "%s:serial->private "
>  			"is NULL, status=%d\n", __func__, status);
>  		return;
>  	}
> -
>  	/* do not resubmit urb if it has any status error */
>  	if (status) {
>  		dev_err(&port->dev,
> -- 
> 2.34.1
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch did many different things all at once, making it difficult
  to review.  All Linux kernel patches need to only do one thing at a
  time.  If you need to do multiple things (such as clean up all coding
  style issues in a file/driver), do it in a sequence of patches, each
  one doing only one thing.  This will make it easier to review the
  patches to ensure that they are correct, and to help alleviate any
  merge issues that larger patches can cause.

- It looks like you did not use your "real" name for the patch on either
  the Signed-off-by: line, or the From: line (both of which have to
  match).  Please read the kernel file,
  Documentation/process/submitting-patches.rst for how to do this
  correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ