diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-08-11 11:18:30 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-08-16 11:55:07 -0400 |
commit | 1d88f831d20c10b5633cd71117917cd04a0735a8 (patch) | |
tree | 023a5b137c228221c64d191179a5ad8a09d3ecb9 | |
parent | ca05189716c2ce02c60303e9c1228a61d1cb9542 (diff) |
[media] tc358743: don't use variable length array for I2C writes
drivers/media/i2c/tc358743.c:148:19: warning: Variable length array is used.
As the maximum size is 1026, we can't use dynamic var, as it
would otherwise spend 1056 bytes of the stack at i2c_wr() function.
So, allocate a buffer with the allowed maximum size together with
the state var.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Mats Randgaard <matrandg@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/i2c/tc358743.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 2e926317d7e9..fe42c9a1cb78 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c | |||
@@ -59,6 +59,9 @@ MODULE_LICENSE("GPL"); | |||
59 | #define EDID_NUM_BLOCKS_MAX 8 | 59 | #define EDID_NUM_BLOCKS_MAX 8 |
60 | #define EDID_BLOCK_SIZE 128 | 60 | #define EDID_BLOCK_SIZE 128 |
61 | 61 | ||
62 | /* Max transfer size done by I2C transfer functions */ | ||
63 | #define MAX_XFER_SIZE (EDID_NUM_BLOCKS_MAX * EDID_BLOCK_SIZE + 2) | ||
64 | |||
62 | static const struct v4l2_dv_timings_cap tc358743_timings_cap = { | 65 | static const struct v4l2_dv_timings_cap tc358743_timings_cap = { |
63 | .type = V4L2_DV_BT_656_1120, | 66 | .type = V4L2_DV_BT_656_1120, |
64 | /* keep this initialization for compatibility with GCC < 4.4.6 */ | 67 | /* keep this initialization for compatibility with GCC < 4.4.6 */ |
@@ -94,6 +97,9 @@ struct tc358743_state { | |||
94 | /* edid */ | 97 | /* edid */ |
95 | u8 edid_blocks_written; | 98 | u8 edid_blocks_written; |
96 | 99 | ||
100 | /* used by i2c_wr() */ | ||
101 | u8 wr_data[MAX_XFER_SIZE]; | ||
102 | |||
97 | struct v4l2_dv_timings timings; | 103 | struct v4l2_dv_timings timings; |
98 | u32 mbus_fmt_code; | 104 | u32 mbus_fmt_code; |
99 | 105 | ||
@@ -143,9 +149,13 @@ static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) | |||
143 | { | 149 | { |
144 | struct tc358743_state *state = to_state(sd); | 150 | struct tc358743_state *state = to_state(sd); |
145 | struct i2c_client *client = state->i2c_client; | 151 | struct i2c_client *client = state->i2c_client; |
152 | u8 *data = state->wr_data; | ||
146 | int err, i; | 153 | int err, i; |
147 | struct i2c_msg msg; | 154 | struct i2c_msg msg; |
148 | u8 data[2 + n]; | 155 | |
156 | if ((2 + n) > sizeof(state->wr_data)) | ||
157 | v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n", | ||
158 | reg, 2 + n); | ||
149 | 159 | ||
150 | msg.addr = client->addr; | 160 | msg.addr = client->addr; |
151 | msg.buf = data; | 161 | msg.buf = data; |