Skip to content

Commit 9a43816

Browse files
labbottdavem330
authored andcommitted
mISDN: Remove VLAs
There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Remove the VLAs from the mISDN code by switching to using kstrdup in one place and using an upper bound in another. Signed-off-by: Laura Abbott <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b16520f commit 9a43816

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

drivers/isdn/mISDN/dsp_hwec.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ void dsp_hwec_enable(struct dsp *dsp, const char *arg)
6868
goto _do;
6969

7070
{
71-
char _dup[len + 1];
7271
char *dup, *tok, *name, *val;
7372
int tmp;
7473

75-
strcpy(_dup, arg);
76-
dup = _dup;
74+
dup = kstrdup(arg, GFP_ATOMIC);
75+
if (!dup)
76+
return;
7777

7878
while ((tok = strsep(&dup, ","))) {
7979
if (!strlen(tok))
@@ -89,6 +89,8 @@ void dsp_hwec_enable(struct dsp *dsp, const char *arg)
8989
deftaps = tmp;
9090
}
9191
}
92+
93+
kfree(dup);
9294
}
9395

9496
_do:

drivers/isdn/mISDN/l1oip_core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
279279
u16 timebase, u8 *buf, int len)
280280
{
281281
u8 *p;
282-
u8 frame[len + 32];
282+
u8 frame[MAX_DFRAME_LEN_L1 + 32];
283283
struct socket *socket = NULL;
284284

285285
if (debug & DEBUG_L1OIP_MSG)
@@ -902,7 +902,11 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
902902
p = skb->data;
903903
l = skb->len;
904904
while (l) {
905-
ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME;
905+
/*
906+
* This is technically bounded by L1OIP_MAX_PERFRAME but
907+
* MAX_DFRAME_LEN_L1 < L1OIP_MAX_PERFRAME
908+
*/
909+
ll = (l < MAX_DFRAME_LEN_L1) ? l : MAX_DFRAME_LEN_L1;
906910
l1oip_socket_send(hc, 0, dch->slot, 0,
907911
hc->chan[dch->slot].tx_counter++, p, ll);
908912
p += ll;
@@ -1140,7 +1144,11 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
11401144
p = skb->data;
11411145
l = skb->len;
11421146
while (l) {
1143-
ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME;
1147+
/*
1148+
* This is technically bounded by L1OIP_MAX_PERFRAME but
1149+
* MAX_DFRAME_LEN_L1 < L1OIP_MAX_PERFRAME
1150+
*/
1151+
ll = (l < MAX_DFRAME_LEN_L1) ? l : MAX_DFRAME_LEN_L1;
11441152
l1oip_socket_send(hc, hc->codec, bch->slot, 0,
11451153
hc->chan[bch->slot].tx_counter, p, ll);
11461154
hc->chan[bch->slot].tx_counter += ll;

0 commit comments

Comments
 (0)