diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-18 18:10:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-18 18:10:05 -0500 |
commit | 3ea369eea07eb64adf36a6fb7fddb5d082c84143 (patch) | |
tree | 976e44b7baf67bc1f9837ebed447e4b686ad4187 /drivers/media/tuners/e4000.c | |
parent | a310410f616c78f24490de1274487a7b7b137d97 (diff) | |
parent | 3cdcf7369cdb3406c61090e453b78cb8d4882ef8 (diff) |
Merge branch 'topic/kbuild-fixes-for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
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
...
Diffstat (limited to 'drivers/media/tuners/e4000.c')
-rw-r--r-- | drivers/media/tuners/e4000.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c index 6c96e4898777..72971a8d3c37 100644 --- a/drivers/media/tuners/e4000.c +++ b/drivers/media/tuners/e4000.c | |||
@@ -21,20 +21,30 @@ | |||
21 | #include "e4000_priv.h" | 21 | #include "e4000_priv.h" |
22 | #include <linux/math64.h> | 22 | #include <linux/math64.h> |
23 | 23 | ||
24 | /* Max transfer size done by I2C transfer functions */ | ||
25 | #define MAX_XFER_SIZE 64 | ||
26 | |||
24 | /* write multiple registers */ | 27 | /* write multiple registers */ |
25 | static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) | 28 | static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) |
26 | { | 29 | { |
27 | int ret; | 30 | int ret; |
28 | u8 buf[1 + len]; | 31 | u8 buf[MAX_XFER_SIZE]; |
29 | struct i2c_msg msg[1] = { | 32 | struct i2c_msg msg[1] = { |
30 | { | 33 | { |
31 | .addr = priv->cfg->i2c_addr, | 34 | .addr = priv->cfg->i2c_addr, |
32 | .flags = 0, | 35 | .flags = 0, |
33 | .len = sizeof(buf), | 36 | .len = 1 + len, |
34 | .buf = buf, | 37 | .buf = buf, |
35 | } | 38 | } |
36 | }; | 39 | }; |
37 | 40 | ||
41 | if (1 + len > sizeof(buf)) { | ||
42 | dev_warn(&priv->i2c->dev, | ||
43 | "%s: i2c wr reg=%04x: len=%d is too big!\n", | ||
44 | KBUILD_MODNAME, reg, len); | ||
45 | return -EINVAL; | ||
46 | } | ||
47 | |||
38 | buf[0] = reg; | 48 | buf[0] = reg; |
39 | memcpy(&buf[1], val, len); | 49 | memcpy(&buf[1], val, len); |
40 | 50 | ||
@@ -54,7 +64,7 @@ static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) | |||
54 | static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) | 64 | static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) |
55 | { | 65 | { |
56 | int ret; | 66 | int ret; |
57 | u8 buf[len]; | 67 | u8 buf[MAX_XFER_SIZE]; |
58 | struct i2c_msg msg[2] = { | 68 | struct i2c_msg msg[2] = { |
59 | { | 69 | { |
60 | .addr = priv->cfg->i2c_addr, | 70 | .addr = priv->cfg->i2c_addr, |
@@ -64,11 +74,18 @@ static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) | |||
64 | }, { | 74 | }, { |
65 | .addr = priv->cfg->i2c_addr, | 75 | .addr = priv->cfg->i2c_addr, |
66 | .flags = I2C_M_RD, | 76 | .flags = I2C_M_RD, |
67 | .len = sizeof(buf), | 77 | .len = len, |
68 | .buf = buf, | 78 | .buf = buf, |
69 | } | 79 | } |
70 | }; | 80 | }; |
71 | 81 | ||
82 | if (len > sizeof(buf)) { | ||
83 | dev_warn(&priv->i2c->dev, | ||
84 | "%s: i2c rd reg=%04x: len=%d is too big!\n", | ||
85 | KBUILD_MODNAME, reg, len); | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | |||
72 | ret = i2c_transfer(priv->i2c, msg, 2); | 89 | ret = i2c_transfer(priv->i2c, msg, 2); |
73 | if (ret == 2) { | 90 | if (ret == 2) { |
74 | memcpy(val, buf, len); | 91 | memcpy(val, buf, len); |