Skip to content

Commit d0bcdff

Browse files
dstarke-siemensgregkh
authored andcommitted
tty: n_gsm: fix wrong command retry handling
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010. See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516 The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to the newer 27.010 here. Chapter 5.7.3 states that the valid range for the maximum number of retransmissions (N2) is from 0 to 255 (both including). gsm_config() fails to limit this range correctly. Furthermore, gsm_control_retransmit() handles this number incorrectly by performing N2 - 1 retransmission attempts. Setting N2 to zero results in more than 255 retransmission attempts. Fix the range check in gsm_config() and the value handling in gsm_control_send() and gsm_control_retransmit() to comply with 3GPP 27.010. Fixes: e1eaea4 ("tty: n_gsm line discipline") Cc: [email protected] Signed-off-by: Daniel Starke <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 17eac65 commit d0bcdff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/tty/n_gsm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,6 @@ static void gsm_control_retransmit(struct timer_list *t)
13541354
spin_lock_irqsave(&gsm->control_lock, flags);
13551355
ctrl = gsm->pending_cmd;
13561356
if (ctrl) {
1357-
gsm->cretries--;
13581357
if (gsm->cretries == 0) {
13591358
gsm->pending_cmd = NULL;
13601359
ctrl->error = -ETIMEDOUT;
@@ -1363,6 +1362,7 @@ static void gsm_control_retransmit(struct timer_list *t)
13631362
wake_up(&gsm->event);
13641363
return;
13651364
}
1365+
gsm->cretries--;
13661366
gsm_control_transmit(gsm, ctrl);
13671367
mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100);
13681368
}
@@ -1403,7 +1403,7 @@ static struct gsm_control *gsm_control_send(struct gsm_mux *gsm,
14031403

14041404
/* If DLCI0 is in ADM mode skip retries, it won't respond */
14051405
if (gsm->dlci[0]->mode == DLCI_MODE_ADM)
1406-
gsm->cretries = 1;
1406+
gsm->cretries = 0;
14071407
else
14081408
gsm->cretries = gsm->n2;
14091409

@@ -2343,7 +2343,7 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
23432343
/* Check the MRU/MTU range looks sane */
23442344
if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8)
23452345
return -EINVAL;
2346-
if (c->n2 < 3)
2346+
if (c->n2 > 255)
23472347
return -EINVAL;
23482348
if (c->encapsulation > 1) /* Basic, advanced, no I */
23492349
return -EINVAL;

0 commit comments

Comments
 (0)