This is a note to let you know that I've just added the patch titled

    media: af9035: Don't use dynamic static allocation

to the 3.10-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     media-af9035-don-t-use-dynamic-static-allocation.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 7760e148350bf6df95662bc0db3734e9d991cb03 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <[email protected]>
Date: Sat, 2 Nov 2013 08:07:12 -0300
Subject: media: af9035: Don't use dynamic static allocation

From: Mauro Carvalho Chehab <[email protected]>

commit 7760e148350bf6df95662bc0db3734e9d991cb03 upstream.

Dynamic static allocation is evil, as Kernel stack is too low, and
compilation complains about it on some archs:
        drivers/media/usb/dvb-usb-v2/af9035.c:142:1: warning: 'af9035_wr_regs' 
uses dynamic stack allocation [enabled by default]
        drivers/media/usb/dvb-usb-v2/af9035.c:305:1: warning: 
'af9035_i2c_master_xfer' uses dynamic stack allocation [enabled by default]
Instead, let's enforce a limit for the buffer to be the max size of
a control URB payload data (64 bytes).

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Hans Verkuil <[email protected]>
Reviewed-by: Antti Palosaari <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 drivers/media/usb/dvb-usb-v2/af9035.c |   29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -21,6 +21,9 @@
 
 #include "af9035.h"
 
+/* Max transfer size done by I2C transfer functions */
+#define MAX_XFER_SIZE  64
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 static u16 af9035_checksum(const u8 *buf, size_t len)
@@ -125,10 +128,16 @@ exit:
 /* write multiple registers */
 static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
 {
-       u8 wbuf[6 + len];
+       u8 wbuf[MAX_XFER_SIZE];
        u8 mbox = (reg >> 16) & 0xff;
        struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL };
 
+       if (6 + len > sizeof(wbuf)) {
+               dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
+                        KBUILD_MODNAME, len);
+               return -EOPNOTSUPP;
+       }
+
        wbuf[0] = len;
        wbuf[1] = 2;
        wbuf[2] = 0;
@@ -227,9 +236,16 @@ static int af9035_i2c_master_xfer(struct
                                        msg[1].len);
                } else {
                        /* I2C */
-                       u8 buf[5 + msg[0].len];
+                       u8 buf[MAX_XFER_SIZE];
                        struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
                                        buf, msg[1].len, msg[1].buf };
+
+                       if (5 + msg[0].len > sizeof(buf)) {
+                               dev_warn(&d->udev->dev,
+                                        "%s: i2c xfer: len=%d is too big!\n",
+                                        KBUILD_MODNAME, msg[0].len);
+                               return -EOPNOTSUPP;
+                       }
                        req.mbox |= ((msg[0].addr & 0x80)  >>  3);
                        buf[0] = msg[1].len;
                        buf[1] = msg[0].addr << 1;
@@ -256,9 +272,16 @@ static int af9035_i2c_master_xfer(struct
                                        msg[0].len - 3);
                } else {
                        /* I2C */
-                       u8 buf[5 + msg[0].len];
+                       u8 buf[MAX_XFER_SIZE];
                        struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf,
                                        0, NULL };
+
+                       if (5 + msg[0].len > sizeof(buf)) {
+                               dev_warn(&d->udev->dev,
+                                        "%s: i2c xfer: len=%d is too big!\n",
+                                        KBUILD_MODNAME, msg[0].len);
+                               return -EOPNOTSUPP;
+                       }
                        req.mbox |= ((msg[0].addr & 0x80)  >>  3);
                        buf[0] = msg[0].len;
                        buf[1] = msg[0].addr << 1;


Patches currently in stable-queue which might be from [email protected] are

queue-3.10/media-af9015-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-dw2102-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-af9035-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-stb0899_drv-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-dibusb-common-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-cx18-struct-i2c_client-is-too-big-for-stack.patch
queue-3.10/media-tuner-xc2028-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-cimax2-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-tuners-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-dvb-frontends-again-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-dvb-frontends-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-stv090x-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-s5h1420-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-av7110_hw-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-stv0367-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-lirc_zilog-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-cxusb-don-t-use-dynamic-static-allocation.patch
queue-3.10/media-mxl111sf-don-t-use-dynamic-static-allocation.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to