aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2013-11-02 07:07:12 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-11-08 06:45:45 -0500
commit7760e148350bf6df95662bc0db3734e9d991cb03 (patch)
tree086ed0e50fac1a4602253115eb7e39c0713add2c
parent65e2f1cb3fe0f0630834b9517ba8f631936f325c (diff)
[media] af9035: Don't use dynamic static allocation
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 <m.chehab@samsung.com> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 1ea17dc2a76e..c8fcd78425bd 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -21,6 +21,9 @@
21 21
22#include "af9035.h" 22#include "af9035.h"
23 23
24/* Max transfer size done by I2C transfer functions */
25#define MAX_XFER_SIZE 64
26
24DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 27DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
25 28
26static u16 af9035_checksum(const u8 *buf, size_t len) 29static u16 af9035_checksum(const u8 *buf, size_t len)
@@ -126,10 +129,16 @@ exit:
126/* write multiple registers */ 129/* write multiple registers */
127static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len) 130static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
128{ 131{
129 u8 wbuf[6 + len]; 132 u8 wbuf[MAX_XFER_SIZE];
130 u8 mbox = (reg >> 16) & 0xff; 133 u8 mbox = (reg >> 16) & 0xff;
131 struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL }; 134 struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL };
132 135
136 if (6 + len > sizeof(wbuf)) {
137 dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
138 KBUILD_MODNAME, len);
139 return -EOPNOTSUPP;
140 }
141
133 wbuf[0] = len; 142 wbuf[0] = len;
134 wbuf[1] = 2; 143 wbuf[1] = 2;
135 wbuf[2] = 0; 144 wbuf[2] = 0;
@@ -228,9 +237,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
228 msg[1].len); 237 msg[1].len);
229 } else { 238 } else {
230 /* I2C */ 239 /* I2C */
231 u8 buf[5 + msg[0].len]; 240 u8 buf[MAX_XFER_SIZE];
232 struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), 241 struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
233 buf, msg[1].len, msg[1].buf }; 242 buf, msg[1].len, msg[1].buf };
243
244 if (5 + msg[0].len > sizeof(buf)) {
245 dev_warn(&d->udev->dev,
246 "%s: i2c xfer: len=%d is too big!\n",
247 KBUILD_MODNAME, msg[0].len);
248 return -EOPNOTSUPP;
249 }
234 req.mbox |= ((msg[0].addr & 0x80) >> 3); 250 req.mbox |= ((msg[0].addr & 0x80) >> 3);
235 buf[0] = msg[1].len; 251 buf[0] = msg[1].len;
236 buf[1] = msg[0].addr << 1; 252 buf[1] = msg[0].addr << 1;
@@ -257,9 +273,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
257 msg[0].len - 3); 273 msg[0].len - 3);
258 } else { 274 } else {
259 /* I2C */ 275 /* I2C */
260 u8 buf[5 + msg[0].len]; 276 u8 buf[MAX_XFER_SIZE];
261 struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf, 277 struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf,
262 0, NULL }; 278 0, NULL };
279
280 if (5 + msg[0].len > sizeof(buf)) {
281 dev_warn(&d->udev->dev,
282 "%s: i2c xfer: len=%d is too big!\n",
283 KBUILD_MODNAME, msg[0].len);
284 return -EOPNOTSUPP;
285 }
263 req.mbox |= ((msg[0].addr & 0x80) >> 3); 286 req.mbox |= ((msg[0].addr & 0x80) >> 3);
264 buf[0] = msg[0].len; 287 buf[0] = msg[0].len;
265 buf[1] = msg[0].addr << 1; 288 buf[1] = msg[0].addr << 1;