Commit 5eb35a6c authored by Stefan Schmidt's avatar Stefan Schmidt Committed by Marcel Holtmann

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: 6cc33eba ("ieee802154: atusb: try to read permanent extended
address from device")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarStefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 2fd2b550
...@@ -721,7 +721,7 @@ static int atusb_get_and_show_chip(struct atusb *atusb) ...@@ -721,7 +721,7 @@ static int atusb_get_and_show_chip(struct atusb *atusb)
static int atusb_set_extended_addr(struct atusb *atusb) static int atusb_set_extended_addr(struct atusb *atusb)
{ {
struct usb_device *usb_dev = atusb->usb_dev; struct usb_device *usb_dev = atusb->usb_dev;
unsigned char buffer[IEEE802154_EXTENDED_ADDR_LEN]; unsigned char *buffer;
__le64 extended_addr; __le64 extended_addr;
u64 addr; u64 addr;
int ret; int ret;
...@@ -733,6 +733,10 @@ static int atusb_set_extended_addr(struct atusb *atusb) ...@@ -733,6 +733,10 @@ static int atusb_set_extended_addr(struct atusb *atusb)
return 0; return 0;
} }
buffer = kmalloc(IEEE802154_EXTENDED_ADDR_LEN, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
/* Firmware is new enough so we fetch the address from EEPROM */ /* Firmware is new enough so we fetch the address from EEPROM */
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0, ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
...@@ -740,6 +744,7 @@ static int atusb_set_extended_addr(struct atusb *atusb) ...@@ -740,6 +744,7 @@ static int atusb_set_extended_addr(struct atusb *atusb)
if (ret < 0) { if (ret < 0) {
dev_err(&usb_dev->dev, "failed to fetch extended address, random address set\n"); dev_err(&usb_dev->dev, "failed to fetch extended address, random address set\n");
ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr); ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
kfree(buffer);
return ret; return ret;
} }
...@@ -755,6 +760,7 @@ static int atusb_set_extended_addr(struct atusb *atusb) ...@@ -755,6 +760,7 @@ static int atusb_set_extended_addr(struct atusb *atusb)
&addr); &addr);
} }
kfree(buffer);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment