[6/9] tty: n_gsm: increase malformed counter for malformed control frames

Message ID 20230405054730.3850-6-daniel.starke@siemens.com
State New
Headers
Series [1/9] tty: n_gsm: fix redundant assignment of gsm->encoding |

Commit Message

D. Starke April 5, 2023, 5:47 a.m. UTC
  From: Daniel Starke <daniel.starke@siemens.com>

The malformed counter in gsm_mux is already increased in case of errors
detected in gsm_queue() and gsm1_receive(). gsm_dlci_command() also
detects a case for a malformed frame but does not increase the malformed
counter yet.

Fix this by also increasing the gsm_mux malformed counter in case of a
malformed frame in gsm_dlci_command().

Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
---
 drivers/tty/n_gsm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Ilpo Järvinen April 5, 2023, 8:44 a.m. UTC | #1
On Wed, 5 Apr 2023, D. Starke wrote:

> From: Daniel Starke <daniel.starke@siemens.com>
> 
> The malformed counter in gsm_mux is already increased in case of errors
> detected in gsm_queue() and gsm1_receive(). gsm_dlci_command() also
> detects a case for a malformed frame but does not increase the malformed
> counter yet.
> 
> Fix this by also increasing the gsm_mux malformed counter in case of a
> malformed frame in gsm_dlci_command().
> 
> Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
> ---
>  drivers/tty/n_gsm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index 9f6669686c59..317aa67ed169 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -2454,8 +2454,10 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len)
>  	data += dlen;
>  
>  	/* Malformed command? */
> -	if (clen > len)
> +	if (clen > len) {
> +		dlci->gsm->malformed++;
>  		return;
> +	}

Should this change have a Fixes: tag? Or is ->malformed just an internal 
variable which is not exposed anywhere (in which case state that in the 
changelog)?
  
D. Starke April 6, 2023, 5:45 a.m. UTC | #2
> > +		dlci->gsm->malformed++;
> >  		return;
> > +	}
> 
> Should this change have a Fixes: tag? Or is ->malformed just an internal 
> variable which is not exposed anywhere (in which case state that in the 
> changelog)?

Correct, the variable is not yet exposed anywhere. I will add a remark for
this in the changelog.

Best regards,
Daniel Starke
  

Patch

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 9f6669686c59..317aa67ed169 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2454,8 +2454,10 @@  static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len)
 	data += dlen;
 
 	/* Malformed command? */
-	if (clen > len)
+	if (clen > len) {
+		dlci->gsm->malformed++;
 		return;
+	}
 
 	if (command & 1)
 		gsm_control_message(dlci->gsm, command, data, clen);