Merge branch 'topic/kbuild-fixes-for-next' of git://git.kernel.org/pub/scm/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Nov 2013 23:10:05 +0000 (15:10 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Nov 2013 23:10:05 +0000 (15:10 -0800)
Pull media build fixes from Mauro Carvalho Chehab:
 "A series of patches that fix compilation on non-x86 archs.

  While most of them are just build fixes, there are some fixes for real
  bugs, as there are a number of drivers using dynamic stack allocation.
  A few of those might be considered a security risk, if the i2c-dev
  module is loaded, as someone could be sending very long I2C data that
  could potentially overflow the Kernel stack.  Ok, as using /dev/i2c-*
  devnodes usually requires root on usual distros, and exploiting it
  would require a DVB board or USB stick, the risk is not high"

* 'topic/kbuild-fixes-for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (28 commits)
  [media] platform drivers: Fix build on frv arch
  [media] lirc_zilog: Don't use dynamic static allocation
  [media] mxl111sf: Don't use dynamic static allocation
  [media] af9035: Don't use dynamic static allocation
  [media] af9015: Don't use dynamic static allocation
  [media] dw2102: Don't use dynamic static allocation
  [media] dibusb-common: Don't use dynamic static allocation
  [media] cxusb: Don't use dynamic static allocation
  [media] v4l2-async: Don't use dynamic static allocation
  [media] cimax2: Don't use dynamic static allocation
  [media] tuner-xc2028: Don't use dynamic static allocation
  [media] tuners: Don't use dynamic static allocation
  [media] av7110_hw: Don't use dynamic static allocation
  [media] stv090x: Don't use dynamic static allocation
  [media] stv0367: Don't use dynamic static allocation
  [media] stb0899_drv: Don't use dynamic static allocation
  [media] dvb-frontends: Don't use dynamic static allocation
  [media] dvb-frontends: Don't use dynamic static allocation
  [media] s5h1420: Don't use dynamic static allocation
  [media] uvc/lirc_serial: Fix some warnings on parisc arch
  ...

1  2 
drivers/media/rc/iguanair.c
drivers/media/tuners/e4000.c
drivers/staging/media/lirc/lirc_serial.c

index b53626ba6f4954bf1bbe4e7caf954f2f597247d6,7f05e197680bc7daacbb4072828c83efd4986fd5..fdae05c4f3775d7f54050c8776f0b882ac2fe630
@@@ -207,7 -207,7 +207,7 @@@ static int iguanair_send(struct iguanai
  {
        int rc;
  
 -      INIT_COMPLETION(ir->completion);
 +      reinit_completion(&ir->completion);
  
        ir->urb_out->transfer_buffer_length = size;
        rc = usb_submit_urb(ir->urb_out, GFP_KERNEL);
@@@ -308,22 -308,12 +308,12 @@@ static int iguanair_set_tx_carrier(stru
                cycles = DIV_ROUND_CLOSEST(24000000, carrier * 2) -
                                                        ir->cycle_overhead;
  
-               /*  make up the the remainer of 4-cycle blocks */
-               switch (cycles & 3) {
-               case 0:
-                       sevens = 0;
-                       break;
-               case 1:
-                       sevens = 3;
-                       break;
-               case 2:
-                       sevens = 2;
-                       break;
-               case 3:
-                       sevens = 1;
-                       break;
-               }
+               /*
+                * Calculate minimum number of 7 cycles needed so
+                * we are left with a multiple of 4; so we want to have
+                * (sevens * 7) & 3 == cycles & 3
+                */
+               sevens = (4 - cycles) & 3;
                fours = (cycles - sevens * 7) / 4;
  
                /* magic happens here */
index 6c96e4898777f29f5c9ae4457d488e9424b32f2b,c9cc1232f2e5d89f21973dd437392ec1edcb44fa..72971a8d3c37978ef1c42b6a2523bb4cb8e92f4a
   */
  
  #include "e4000_priv.h"
 +#include <linux/math64.h>
  
+ /* Max transfer size done by I2C transfer functions */
+ #define MAX_XFER_SIZE  64
  /* write multiple registers */
  static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
  {
        int ret;
-       u8 buf[1 + len];
+       u8 buf[MAX_XFER_SIZE];
        struct i2c_msg msg[1] = {
                {
                        .addr = priv->cfg->i2c_addr,
                        .flags = 0,
-                       .len = sizeof(buf),
+                       .len = 1 + len,
                        .buf = buf,
                }
        };
  
+       if (1 + len > sizeof(buf)) {
+               dev_warn(&priv->i2c->dev,
+                        "%s: i2c wr reg=%04x: len=%d is too big!\n",
+                        KBUILD_MODNAME, reg, len);
+               return -EINVAL;
+       }
        buf[0] = reg;
        memcpy(&buf[1], val, len);
  
@@@ -54,7 -63,7 +64,7 @@@
  static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
  {
        int ret;
-       u8 buf[len];
+       u8 buf[MAX_XFER_SIZE];
        struct i2c_msg msg[2] = {
                {
                        .addr = priv->cfg->i2c_addr,
                }, {
                        .addr = priv->cfg->i2c_addr,
                        .flags = I2C_M_RD,
-                       .len = sizeof(buf),
+                       .len = len,
                        .buf = buf,
                }
        };
  
+       if (len > sizeof(buf)) {
+               dev_warn(&priv->i2c->dev,
+                        "%s: i2c rd reg=%04x: len=%d is too big!\n",
+                        KBUILD_MODNAME, reg, len);
+               return -EINVAL;
+       }
        ret = i2c_transfer(priv->i2c, msg, 2);
        if (ret == 2) {
                memcpy(val, buf, len);
@@@ -234,7 -250,7 +251,7 @@@ static int e4000_set_params(struct dvb_
         * or more.
         */
        f_vco = c->frequency * e4000_pll_lut[i].mul;
 -      sigma_delta = 0x10000UL * (f_vco % priv->cfg->clock) / priv->cfg->clock;
 +      sigma_delta = div_u64(0x10000ULL * (f_vco % priv->cfg->clock), priv->cfg->clock);
        buf[0] = f_vco / priv->cfg->clock;
        buf[1] = (sigma_delta >> 0) & 0xff;
        buf[2] = (sigma_delta >> 8) & 0xff;
index f6bc4c91ab35f4737338e945a70b7a7fedf84f4c,7b3be2346b4b5a712fdb1e5e1e86187de05806f4..2e3a98575d47f9fbdddebecdd2a17d9741ffd09e
@@@ -67,7 -67,7 +67,7 @@@
  #include <linux/delay.h>
  #include <linux/poll.h>
  #include <linux/platform_device.h>
 -
 +#include <linux/gpio.h>
  #include <linux/io.h>
  #include <linux/irq.h>
  #include <linux/fcntl.h>
@@@ -321,7 -321,7 +321,7 @@@ static void on(void
         * status LED and ground
         */
        if (type == LIRC_NSLU2) {
 -              gpio_line_set(NSLU2_LED_GRN, IXP4XX_GPIO_LOW);
 +              gpio_set_value(NSLU2_LED_GRN, 0);
                return;
        }
  #endif
@@@ -335,7 -335,7 +335,7 @@@ static void off(void
  {
  #ifdef CONFIG_LIRC_SERIAL_NSLU2
        if (type == LIRC_NSLU2) {
 -              gpio_line_set(NSLU2_LED_GRN, IXP4XX_GPIO_HIGH);
 +              gpio_set_value(NSLU2_LED_GRN, 1);
                return;
        }
  #endif
@@@ -707,7 -707,8 +707,8 @@@ static irqreturn_t irq_handler(int i, v
                                pr_warn("ignoring spike: %d %d %lx %lx %lx %lx\n",
                                        dcd, sense,
                                        tv.tv_sec, lasttv.tv_sec,
-                                       tv.tv_usec, lasttv.tv_usec);
+                                       (unsigned long)tv.tv_usec,
+                                       (unsigned long)lasttv.tv_usec);
                                continue;
                        }
  
                                pr_warn("%d %d %lx %lx %lx %lx\n",
                                        dcd, sense,
                                        tv.tv_sec, lasttv.tv_sec,
-                                       tv.tv_usec, lasttv.tv_usec);
+                                       (unsigned long)tv.tv_usec,
+                                       (unsigned long)lasttv.tv_usec);
                                data = PULSE_MASK;
                        } else if (deltv > 15) {
                                data = PULSE_MASK; /* really long time */
                                        pr_warn("AIEEEE: %d %d %lx %lx %lx %lx\n",
                                                dcd, sense,
                                                tv.tv_sec, lasttv.tv_sec,
-                                               tv.tv_usec, lasttv.tv_usec);
+                                               (unsigned long)tv.tv_usec,
+                                               (unsigned long)lasttv.tv_usec);
                                        /*
                                         * detecting pulse while this
                                         * MUST be a space!
@@@ -839,16 -842,6 +842,16 @@@ static int lirc_serial_probe(struct pla
  {
        int i, nlow, nhigh, result;
  
 +#ifdef CONFIG_LIRC_SERIAL_NSLU2
 +      /* This GPIO is used for a LED on the NSLU2 */
 +      result = devm_gpio_request(dev, NSLU2_LED_GRN, "lirc-serial");
 +      if (result)
 +              return result;
 +      result = gpio_direction_output(NSLU2_LED_GRN, 0);
 +      if (result)
 +              return result;
 +#endif
 +
        result = request_irq(irq, irq_handler,
                             (share_irq ? IRQF_SHARED : 0),
                             LIRC_DRIVER_NAME, (void *)&hardware);