Commit 05a974ef authored by Stefan Schmidt's avatar Stefan Schmidt Committed by Marcel Holtmann

ieee802154: atusb: do not use the stack for buffers to make them 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 the buffers already being present in
time of 4.9 being released. This should go into stable as well.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarStefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 8a430ed5
...@@ -117,13 +117,26 @@ static int atusb_read_reg(struct atusb *atusb, uint8_t reg) ...@@ -117,13 +117,26 @@ static int atusb_read_reg(struct atusb *atusb, uint8_t reg)
{ {
struct usb_device *usb_dev = atusb->usb_dev; struct usb_device *usb_dev = atusb->usb_dev;
int ret; int ret;
uint8_t *buffer;
uint8_t value; uint8_t value;
buffer = kmalloc(1, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
dev_dbg(&usb_dev->dev, "atusb: reg = 0x%x\n", reg); dev_dbg(&usb_dev->dev, "atusb: reg = 0x%x\n", reg);
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
ATUSB_REG_READ, ATUSB_REQ_FROM_DEV, ATUSB_REG_READ, ATUSB_REQ_FROM_DEV,
0, reg, &value, 1, 1000); 0, reg, buffer, 1, 1000);
return ret >= 0 ? value : ret;
if (ret >= 0) {
value = buffer[0];
kfree(buffer);
return value;
} else {
kfree(buffer);
return ret;
}
} }
static int atusb_write_subreg(struct atusb *atusb, uint8_t reg, uint8_t mask, static int atusb_write_subreg(struct atusb *atusb, uint8_t reg, uint8_t mask,
...@@ -608,9 +621,13 @@ static const struct ieee802154_ops atusb_ops = { ...@@ -608,9 +621,13 @@ static const struct ieee802154_ops atusb_ops = {
static int atusb_get_and_show_revision(struct atusb *atusb) static int atusb_get_and_show_revision(struct atusb *atusb)
{ {
struct usb_device *usb_dev = atusb->usb_dev; struct usb_device *usb_dev = atusb->usb_dev;
unsigned char buffer[3]; unsigned char *buffer;
int ret; int ret;
buffer = kmalloc(3, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
/* Get a couple of the ATMega Firmware values */ /* Get a couple of the ATMega Firmware values */
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0, ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0,
...@@ -631,15 +648,20 @@ static int atusb_get_and_show_revision(struct atusb *atusb) ...@@ -631,15 +648,20 @@ static int atusb_get_and_show_revision(struct atusb *atusb)
dev_info(&usb_dev->dev, "Please update to version 0.2 or newer"); dev_info(&usb_dev->dev, "Please update to version 0.2 or newer");
} }
kfree(buffer);
return ret; return ret;
} }
static int atusb_get_and_show_build(struct atusb *atusb) static int atusb_get_and_show_build(struct atusb *atusb)
{ {
struct usb_device *usb_dev = atusb->usb_dev; struct usb_device *usb_dev = atusb->usb_dev;
char build[ATUSB_BUILD_SIZE + 1]; char *build;
int ret; int ret;
build = kmalloc(ATUSB_BUILD_SIZE + 1, GFP_KERNEL);
if (!build)
return -ENOMEM;
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0, ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,
build, ATUSB_BUILD_SIZE, 1000); build, ATUSB_BUILD_SIZE, 1000);
...@@ -648,6 +670,7 @@ static int atusb_get_and_show_build(struct atusb *atusb) ...@@ -648,6 +670,7 @@ static int atusb_get_and_show_build(struct atusb *atusb)
dev_info(&usb_dev->dev, "Firmware: build %s\n", build); dev_info(&usb_dev->dev, "Firmware: build %s\n", build);
} }
kfree(build);
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