Skip to content

Commit 2d6a0e9

Browse files
bwhacksdavem330
authored andcommitted
catc: Use heap buffer for memory size test
Allocating USB buffers on the stack is not portable, and no longer works on x86_64 (with VMAP_STACK enabled as per default). Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d411491 commit 2d6a0e9

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

drivers/net/usb/catc.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
776776
struct net_device *netdev;
777777
struct catc *catc;
778778
u8 broadcast[ETH_ALEN];
779-
int i, pktsz, ret;
779+
int pktsz, ret;
780780

781781
if (usb_set_interface(usbdev,
782782
intf->altsetting->desc.bInterfaceNumber, 1)) {
@@ -840,15 +840,24 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
840840
catc->irq_buf, 2, catc_irq_done, catc, 1);
841841

842842
if (!catc->is_f5u011) {
843+
u32 *buf;
844+
int i;
845+
843846
dev_dbg(dev, "Checking memory size\n");
844847

845-
i = 0x12345678;
846-
catc_write_mem(catc, 0x7a80, &i, 4);
847-
i = 0x87654321;
848-
catc_write_mem(catc, 0xfa80, &i, 4);
849-
catc_read_mem(catc, 0x7a80, &i, 4);
848+
buf = kmalloc(4, GFP_KERNEL);
849+
if (!buf) {
850+
ret = -ENOMEM;
851+
goto fail_free;
852+
}
853+
854+
*buf = 0x12345678;
855+
catc_write_mem(catc, 0x7a80, buf, 4);
856+
*buf = 0x87654321;
857+
catc_write_mem(catc, 0xfa80, buf, 4);
858+
catc_read_mem(catc, 0x7a80, buf, 4);
850859

851-
switch (i) {
860+
switch (*buf) {
852861
case 0x12345678:
853862
catc_set_reg(catc, TxBufCount, 8);
854863
catc_set_reg(catc, RxBufCount, 32);
@@ -863,6 +872,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
863872
dev_dbg(dev, "32k Memory\n");
864873
break;
865874
}
875+
876+
kfree(buf);
866877

867878
dev_dbg(dev, "Getting MAC from SEEROM.\n");
868879

0 commit comments

Comments
 (0)