Skip to content

Commit 54d0a3a

Browse files
committed
USB: serial: iuu_phoenix: fix DMA from stack
Stack-allocated buffers cannot be used for DMA (on all architectures) so allocate the flush command buffer using kmalloc(). Fixes: 60a8fc0 ("USB: add iuu_phoenix driver") Cc: stable <stable@vger.kernel.org> # 2.6.25 Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org>
1 parent 0e2d679 commit 54d0a3a

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

drivers/usb/serial/iuu_phoenix.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,36 +532,46 @@ static int iuu_uart_flush(struct usb_serial_port *port)
532532
struct device *dev = &port->dev;
533533
int i;
534534
int status;
535-
u8 rxcmd = IUU_UART_RX;
535+
u8 *rxcmd;
536536
struct iuu_private *priv = usb_get_serial_port_data(port);
537537

538538
if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0)
539539
return -EIO;
540540

541+
rxcmd = kmalloc(1, GFP_KERNEL);
542+
if (!rxcmd)
543+
return -ENOMEM;
544+
545+
rxcmd[0] = IUU_UART_RX;
546+
541547
for (i = 0; i < 2; i++) {
542-
status = bulk_immediate(port, &rxcmd, 1);
548+
status = bulk_immediate(port, rxcmd, 1);
543549
if (status != IUU_OPERATION_OK) {
544550
dev_dbg(dev, "%s - uart_flush_write error\n", __func__);
545-
return status;
551+
goto out_free;
546552
}
547553

548554
status = read_immediate(port, &priv->len, 1);
549555
if (status != IUU_OPERATION_OK) {
550556
dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
551-
return status;
557+
goto out_free;
552558
}
553559

554560
if (priv->len > 0) {
555561
dev_dbg(dev, "%s - uart_flush datalen is : %i\n", __func__, priv->len);
556562
status = read_immediate(port, priv->buf, priv->len);
557563
if (status != IUU_OPERATION_OK) {
558564
dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
559-
return status;
565+
goto out_free;
560566
}
561567
}
562568
}
563569
dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__);
564570
iuu_led(port, 0, 0xF000, 0, 0xFF);
571+
572+
out_free:
573+
kfree(rxcmd);
574+
565575
return status;
566576
}
567577

0 commit comments

Comments
 (0)