diff options
author | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-11-02 06:23:49 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-11-08 06:45:44 -0500 |
commit | 1d7fa359d4c0fbb2756fa01cc47212908d90b7b0 (patch) | |
tree | 68a4eae0b012db593d04c6b8ba4c75b1c14b1272 | |
parent | 64f7ef8afbf89f3c72c4d2472e4914ca198c0668 (diff) |
[media] dibusb-common: 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/dibusb-common.c:124:1: warning: 'dibusb_i2c_msg' 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>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/usb/dvb-usb/dibusb-common.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/media/usb/dvb-usb/dibusb-common.c b/drivers/media/usb/dvb-usb/dibusb-common.c index c2dded92f1d3..6d68af0c49c8 100644 --- a/drivers/media/usb/dvb-usb/dibusb-common.c +++ b/drivers/media/usb/dvb-usb/dibusb-common.c | |||
@@ -12,6 +12,9 @@ | |||
12 | #include <linux/kconfig.h> | 12 | #include <linux/kconfig.h> |
13 | #include "dibusb.h" | 13 | #include "dibusb.h" |
14 | 14 | ||
15 | /* Max transfer size done by I2C transfer functions */ | ||
16 | #define MAX_XFER_SIZE 64 | ||
17 | |||
15 | static int debug; | 18 | static int debug; |
16 | module_param(debug, int, 0644); | 19 | module_param(debug, int, 0644); |
17 | MODULE_PARM_DESC(debug, "set debugging level (1=info (|-able))." DVB_USB_DEBUG_STATUS); | 20 | MODULE_PARM_DESC(debug, "set debugging level (1=info (|-able))." DVB_USB_DEBUG_STATUS); |
@@ -105,11 +108,16 @@ EXPORT_SYMBOL(dibusb2_0_power_ctrl); | |||
105 | static int dibusb_i2c_msg(struct dvb_usb_device *d, u8 addr, | 108 | static int dibusb_i2c_msg(struct dvb_usb_device *d, u8 addr, |
106 | u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) | 109 | u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) |
107 | { | 110 | { |
108 | u8 sndbuf[wlen+4]; /* lead(1) devaddr,direction(1) addr(2) data(wlen) (len(2) (when reading)) */ | 111 | u8 sndbuf[MAX_XFER_SIZE]; /* lead(1) devaddr,direction(1) addr(2) data(wlen) (len(2) (when reading)) */ |
109 | /* write only ? */ | 112 | /* write only ? */ |
110 | int wo = (rbuf == NULL || rlen == 0), | 113 | int wo = (rbuf == NULL || rlen == 0), |
111 | len = 2 + wlen + (wo ? 0 : 2); | 114 | len = 2 + wlen + (wo ? 0 : 2); |
112 | 115 | ||
116 | if (4 + wlen > sizeof(sndbuf)) { | ||
117 | warn("i2c wr: len=%d is too big!\n", wlen); | ||
118 | return -EOPNOTSUPP; | ||
119 | } | ||
120 | |||
113 | sndbuf[0] = wo ? DIBUSB_REQ_I2C_WRITE : DIBUSB_REQ_I2C_READ; | 121 | sndbuf[0] = wo ? DIBUSB_REQ_I2C_WRITE : DIBUSB_REQ_I2C_READ; |
114 | sndbuf[1] = (addr << 1) | (wo ? 0 : 1); | 122 | sndbuf[1] = (addr << 1) | (wo ? 0 : 1); |
115 | 123 | ||