[media] dw2102: get rid of on-stack dma buffer
authorFlorian Mickler <florian@mickler.org>
Mon, 21 Mar 2011 18:33:44 +0000 (15:33 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 20 May 2011 12:27:58 +0000 (09:27 -0300)
usb_control_msg initiates (and waits for completion of) a dma transfer using
the supplied buffer. That buffer thus has to be seperately allocated on
the heap.

In lib/dma_debug.c the function check_for_stack even warns about it:
WARNING: at lib/dma-debug.c:866 check_for_stack

Note: This change is tested to compile only, as I don't have the hardware.

Signed-off-by: Florian Mickler <florian@mickler.org>
Cc: Igor M. Liplianin <liplianin@tut.by>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/dvb-usb/dw2102.c

index f5b9da18f61106bfa891aec4a69d5f839f052b65..5aabfbcb545bb071200cdcb391a4d0c6eb78fb95 100644 (file)
@@ -121,12 +121,16 @@ static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
                        u16 index, u8 * data, u16 len, int flags)
 {
        int ret;
-       u8 u8buf[len];
-
+       u8 *u8buf;
        unsigned int pipe = (flags == DW210X_READ_MSG) ?
                                usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
        u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
 
+       u8buf = kmalloc(len, GFP_KERNEL);
+       if (!u8buf)
+               return -ENOMEM;
+
+
        if (flags == DW210X_WRITE_MSG)
                memcpy(u8buf, data, len);
        ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
@@ -134,6 +138,8 @@ static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
 
        if (flags == DW210X_READ_MSG)
                memcpy(data, u8buf, len);
+
+       kfree(u8buf);
        return ret;
 }