[PATCH master 16/23] net: usb: asix: use dma_alloc for buffers in USB control messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



usb_control_msg() expects DMA-capable memory for its data parameter,
but so far we passed buffers that may not have the correct alignment.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/net/usb/asix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 9d34beab0df3..8ee0bc85348f 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -175,7 +175,7 @@ static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
 	dev_dbg(&dev->edev.dev, "asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
 		cmd, value, index, size);
 
-	buf = malloc(size);
+	buf = dma_alloc(size);
 	if (!buf)
 		goto out;
 
@@ -193,7 +193,7 @@ static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
 		memcpy(data, buf, size);
 	else if (err >= 0)
 		err = -EINVAL;
-	free(buf);
+	dma_free(buf);
 
 out:
 	return err;
@@ -209,7 +209,7 @@ static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
 		cmd, value, index, size);
 
 	if (data) {
-		buf = malloc(size);
+		buf = dma_alloc(size);
 		if (!buf)
 			goto out;
 		memcpy(buf, data, size);
@@ -225,7 +225,7 @@ static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
 		buf,
 		size,
 		USB_CTRL_SET_TIMEOUT);
-	free(buf);
+	dma_free(buf);
 
 out:
 	return err;
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux