From oliver@neukum.org Thu Dec 18 15:58:57 2008 From: Oliver Neukum Date: Thu, 18 Dec 2008 13:16:40 +0100 Subject: Staging: at76_usb: cleanup dma on stack issues To: Joerg Albert , Balint Seeber , Guido Guenther , "Greg Kroah-Hartman" Message-ID: <200812181316.42472.oliver@neukum.org> Content-Disposition: inline - no DMA on stack - cleanup unclear endianness issue Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/at76_usb/at76_usb.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) --- a/drivers/staging/at76_usb/at76_usb.c +++ b/drivers/staging/at76_usb/at76_usb.c @@ -590,18 +590,25 @@ static int at76_remap(struct usb_device static int at76_get_op_mode(struct usb_device *udev) { int ret; - u8 op_mode; + u8 saved; + u8 *op_mode; + op_mode = kmalloc(1, GFP_NOIO); + if (!op_mode) + return -ENOMEM; ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_INTERFACE, 0x01, 0, &op_mode, 1, USB_CTRL_GET_TIMEOUT); + saved = *op_mode; + kfree(op_mode); + if (ret < 0) return ret; else if (ret < 1) return -EIO; else - return op_mode; + return saved; } /* Load a block of the second ("external") part of the firmware */ @@ -714,17 +721,22 @@ static inline int at76_get_mib(struct us /* Return positive number for status, negative for an error */ static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd) { - u8 stat_buf[40]; + u8 *stat_buf; int ret; + stat_buf = kmalloc(40, GFP_NOIO); + if (!stat_buf) + return -ENOMEM; + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22, USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_INTERFACE, cmd, 0, stat_buf, sizeof(stat_buf), USB_CTRL_GET_TIMEOUT); - if (ret < 0) - return ret; + if (ret >= 0) + ret = stat_buf[5]; + kfree(stat_buf); - return stat_buf[5]; + return ret; } #define MAKE_CMD_CASE(c) case (c): return #c @@ -745,7 +757,7 @@ static const char *at76_get_cmd_string(u return "UNKNOWN"; } -static int at76_set_card_command(struct usb_device *udev, int cmd, void *buf, +static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf, int buf_size) { int ret;