Skip to content

Commit 170ebf8

Browse files
tilmanschmidtdavem330
authored andcommitted
bas_gigaset: correctly allocate USB interrupt transfer buffer
Every USB transfer buffer has to be allocated individually by kmalloc. Impact: bugfix, no functional change Signed-off-by: Tilman Schmidt <tilman@imap.cc> Tested-by: Kolja Waschk <kawk@users.sourceforge.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 44c1d6f commit 170ebf8

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎drivers/isdn/gigaset/bas-gigaset.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode");
4646
/* length limit according to Siemens 3070usb-protokoll.doc ch. 2.1 */
4747
#define IF_WRITEBUF 264
4848

49+
/* interrupt pipe message size according to ibid. ch. 2.2 */
50+
#define IP_MSGSIZE 3
51+
4952
/* Values for the Gigaset 307x */
5053
#define USB_GIGA_VENDOR_ID 0x0681
5154
#define USB_3070_PRODUCT_ID 0x0001
@@ -110,7 +113,7 @@ struct bas_cardstate {
110113
unsigned char *rcvbuf; /* AT reply receive buffer */
111114

112115
struct urb *urb_int_in; /* URB for interrupt pipe */
113-
unsigned char int_in_buf[3];
116+
unsigned char *int_in_buf;
114117

115118
spinlock_t lock; /* locks all following */
116119
int basstate; /* bitmap (BS_*) */
@@ -657,7 +660,7 @@ static void read_int_callback(struct urb *urb)
657660
}
658661

659662
/* drop incomplete packets even if the missing bytes wouldn't matter */
660-
if (unlikely(urb->actual_length < 3)) {
663+
if (unlikely(urb->actual_length < IP_MSGSIZE)) {
661664
dev_warn(cs->dev, "incomplete interrupt packet (%d bytes)\n",
662665
urb->actual_length);
663666
goto resubmit;
@@ -2127,6 +2130,7 @@ static void gigaset_reinitbcshw(struct bc_state *bcs)
21272130
static void gigaset_freecshw(struct cardstate *cs)
21282131
{
21292132
/* timers, URBs and rcvbuf are disposed of in disconnect */
2133+
kfree(cs->hw.bas->int_in_buf);
21302134
kfree(cs->hw.bas);
21312135
cs->hw.bas = NULL;
21322136
}
@@ -2140,6 +2144,12 @@ static int gigaset_initcshw(struct cardstate *cs)
21402144
pr_err("out of memory\n");
21412145
return 0;
21422146
}
2147+
ucs->int_in_buf = kmalloc(IP_MSGSIZE, GFP_KERNEL);
2148+
if (!ucs->int_in_buf) {
2149+
kfree(ucs);
2150+
pr_err("out of memory\n");
2151+
return 0;
2152+
}
21432153

21442154
ucs->urb_cmd_in = NULL;
21452155
ucs->urb_cmd_out = NULL;
@@ -2292,7 +2302,7 @@ static int gigaset_probe(struct usb_interface *interface,
22922302
usb_fill_int_urb(ucs->urb_int_in, udev,
22932303
usb_rcvintpipe(udev,
22942304
(endpoint->bEndpointAddress) & 0x0f),
2295-
ucs->int_in_buf, 3, read_int_callback, cs,
2305+
ucs->int_in_buf, IP_MSGSIZE, read_int_callback, cs,
22962306
endpoint->bInterval);
22972307
if ((rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL)) != 0) {
22982308
dev_err(cs->dev, "could not submit interrupt URB: %s\n",

0 commit comments

Comments
 (0)