]> Pileus Git - ~andy/linux/blobdiff - drivers/media/dvb-frontends/mt312.c
[media] dvb-frontends: Don't use dynamic static allocation
[~andy/linux] / drivers / media / dvb-frontends / mt312.c
index ec388c1d6913c73c9458d43695793ff833fcbd67..a74ac0ddb83310ab619870a0f465771ca451eb7a 100644 (file)
@@ -36,6 +36,8 @@
 #include "mt312_priv.h"
 #include "mt312.h"
 
+/* Max transfer size done by I2C transfer functions */
+#define MAX_XFER_SIZE  64
 
 struct mt312_state {
        struct i2c_adapter *i2c;
@@ -96,9 +98,15 @@ static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg,
                       const u8 *src, const size_t count)
 {
        int ret;
-       u8 buf[count + 1];
+       u8 buf[MAX_XFER_SIZE];
        struct i2c_msg msg;
 
+       if (1 + count > sizeof(buf)) {
+               printk(KERN_WARNING
+                      "mt312: write: len=%zd is too big!\n", count);
+               return -EINVAL;
+       }
+
        if (debug) {
                int i;
                dprintk("W(%d):", reg & 0x7f);