[media] friio: get rid of on-stack dma buffers
authorFlorian Mickler <florian@mickler.org>
Mon, 21 Mar 2011 18:33:43 +0000 (15:33 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 20 May 2011 12:27:57 +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: Akihiro Tsukada <tskd2@yahoo.co.jp>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/dvb-usb/friio.c

index 14a65b4aec07320a1dfaa7c9a7bf7d744d3ce458..76159aed9bb084180d3276ec4feecbb630041e32 100644 (file)
@@ -142,17 +142,20 @@ static u32 gl861_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-
 static int friio_ext_ctl(struct dvb_usb_adapter *adap,
                         u32 sat_color, int lnb_on)
 {
        int i;
        int ret;
        struct i2c_msg msg;
-       u8 buf[2];
+       u8 *buf;
        u32 mask;
        u8 lnb = (lnb_on) ? FRIIO_CTL_LNB : 0;
 
+       buf = kmalloc(2, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
        msg.addr = 0x00;
        msg.flags = 0;
        msg.len = 2;
@@ -189,6 +192,7 @@ static int friio_ext_ctl(struct dvb_usb_adapter *adap,
        buf[1] |= FRIIO_CTL_CLK;
        ret += gl861_i2c_xfer(&adap->dev->i2c_adap, &msg, 1);
 
+       kfree(buf);
        return (ret == 70);
 }
 
@@ -219,11 +223,20 @@ static int friio_initialize(struct dvb_usb_device *d)
        int ret;
        int i;
        int retry = 0;
-       u8 rbuf[2];
-       u8 wbuf[3];
+       u8 *rbuf, *wbuf;
 
        deb_info("%s called.\n", __func__);
 
+       wbuf = kmalloc(3, GFP_KERNEL);
+       if (!wbuf)
+               return -ENOMEM;
+
+       rbuf = kmalloc(2, GFP_KERNEL);
+       if (!rbuf) {
+               kfree(wbuf);
+               return -ENOMEM;
+       }
+
        /* use gl861_i2c_msg instead of gl861_i2c_xfer(), */
        /* because the i2c device is not set up yet. */
        wbuf[0] = 0x11;
@@ -358,6 +371,8 @@ restart:
        return 0;
 
 error:
+       kfree(wbuf);
+       kfree(rbuf);
        deb_info("%s:ret == %d\n", __func__, ret);
        return -EIO;
 }
This page took 0.025488 seconds and 5 git commands to generate.