From 8617d09ee375c66b3aa2f6fe26c5b744b156c740 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 3 Jul 2020 19:28:53 +0200 Subject: lapd_core: Ensure we always have some tailroom At some points, e.g. when allocating message buffers from the Tx history, we used to allocate them exactly as large as the defined headroom plus the user data. This means that the underlying PH layer (E1 mostly) had no tailroom to add anything to the end of the message. Especially for DAHDI this is a problem, as we need to make space for two more bytes of frame check sequence (FCS). So let's simply make sure we always have some extra space at the end of such buffers. Change-Id: Id362ce131157c7513d744b0248c7f78fb75c590c Related: OS#4644 --- src/gsm/lapd_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index c77b6632..cf25f3de 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -104,6 +104,7 @@ #define CR_NET2USER_RESP 0 #define LAPD_HEADROOM 56 +#define LAPD_TAILROOM 16 #define SBIT(a) (1 << a) #define ALL_STATES 0xffffffff @@ -120,7 +121,7 @@ struct msgb *lapd_msgb_alloc(int length, const char *name) /* adding space for padding, FIXME: add as an option */ if (length < 21) length = 21; - return msgb_alloc_headroom(length + LAPD_HEADROOM, LAPD_HEADROOM, name); + return msgb_alloc_headroom(length + LAPD_HEADROOM + LAPD_TAILROOM, LAPD_HEADROOM, name); } static inline uint8_t do_mod(uint8_t x, uint8_t m) -- cgit v1.2.3