Skip to content

Commit 5eb35a6

Browse files
Stefan Schmidtholtmann
authored andcommitted
ieee802154: atusb: do not use the stack for address fetching to make it DMA able
From 4.9 we should really avoid using the stack here as this will not be DMA able on various platforms. This changes a buffer that was introduced in the 4.10 merge window. Fixes: 6cc33eb ("ieee802154: atusb: try to read permanent extended address from device") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Stefan Schmidt <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 2fd2b55 commit 5eb35a6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/net/ieee802154/atusb.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ static int atusb_get_and_show_chip(struct atusb *atusb)
721721
static int atusb_set_extended_addr(struct atusb *atusb)
722722
{
723723
struct usb_device *usb_dev = atusb->usb_dev;
724-
unsigned char buffer[IEEE802154_EXTENDED_ADDR_LEN];
724+
unsigned char *buffer;
725725
__le64 extended_addr;
726726
u64 addr;
727727
int ret;
@@ -733,13 +733,18 @@ static int atusb_set_extended_addr(struct atusb *atusb)
733733
return 0;
734734
}
735735

736+
buffer = kmalloc(IEEE802154_EXTENDED_ADDR_LEN, GFP_KERNEL);
737+
if (!buffer)
738+
return -ENOMEM;
739+
736740
/* Firmware is new enough so we fetch the address from EEPROM */
737741
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
738742
ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
739743
buffer, IEEE802154_EXTENDED_ADDR_LEN, 1000);
740744
if (ret < 0) {
741745
dev_err(&usb_dev->dev, "failed to fetch extended address, random address set\n");
742746
ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
747+
kfree(buffer);
743748
return ret;
744749
}
745750

@@ -755,6 +760,7 @@ static int atusb_set_extended_addr(struct atusb *atusb)
755760
&addr);
756761
}
757762

763+
kfree(buffer);
758764
return ret;
759765
}
760766

0 commit comments

Comments
 (0)