Skip to content

Commit 535bf60

Browse files
dstarke-siemensgregkh
authored andcommitted
tty: n_gsm: fix insufficient txframe size
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.2 states that the maximum frame size (N1) refers to the length of the information field (i.e. user payload). However, 'txframe' stores the whole frame including frame header, checksum and start/end flags. We also need to consider the byte stuffing overhead. Define constant for the protocol overhead and adjust the 'txframe' size calculation accordingly to reserve enough space for a complete mux frame including byte stuffing for advanced option mode. Note that no byte stuffing is applied to the start and end flag. Also use MAX_MTU instead of MAX_MRU as this buffer is used for data transmission. 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 a24b4b2 commit 535bf60

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/tty/n_gsm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ module_param(debug, int, 0600);
7373
*/
7474
#define MAX_MRU 1500
7575
#define MAX_MTU 1500
76+
/* SOF, ADDR, CTRL, LEN1, LEN2, ..., FCS, EOF */
77+
#define PROT_OVERHEAD 7
7678
#define GSM_NET_TX_TIMEOUT (HZ*10)
7779

7880
/*
@@ -2264,7 +2266,7 @@ static struct gsm_mux *gsm_alloc_mux(void)
22642266
kfree(gsm);
22652267
return NULL;
22662268
}
2267-
gsm->txframe = kmalloc(2 * MAX_MRU + 2, GFP_KERNEL);
2269+
gsm->txframe = kmalloc(2 * (MAX_MTU + PROT_OVERHEAD - 1), GFP_KERNEL);
22682270
if (gsm->txframe == NULL) {
22692271
kfree(gsm->buf);
22702272
kfree(gsm);

0 commit comments

Comments
 (0)