diff options
| author | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-11-02 07:16:47 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-11-08 06:45:46 -0500 |
| commit | ac5b4b6bf0c84c48d7e2e3fce22e35b04282ba76 (patch) | |
| tree | cb63d3cb26bdf01c5df52afeeb6d18e8131ba091 | |
| parent | c98300a0e8cf160aaea60bc05d2cd156a7666173 (diff) | |
[media] lirc_zilog: Don't use dynamic static allocation
Dynamic static allocation is evil, as Kernel stack is too low, and
ompilation complains about it on some archs:
drivers/staging/media/lirc/lirc_zilog.c:967:1: warning: 'read' uses dynamic stack allocation [enabled by default]
Instead, let's enforce a limit for the buffer to be 64. That should
be more than enough.
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/staging/media/lirc/lirc_zilog.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c index 11d5338b4f2f..0feeaadf29dc 100644 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ b/drivers/staging/media/lirc/lirc_zilog.c | |||
| @@ -61,6 +61,9 @@ | |||
| 61 | #include <media/lirc_dev.h> | 61 | #include <media/lirc_dev.h> |
| 62 | #include <media/lirc.h> | 62 | #include <media/lirc.h> |
| 63 | 63 | ||
| 64 | /* Max transfer size done by I2C transfer functions */ | ||
| 65 | #define MAX_XFER_SIZE 64 | ||
| 66 | |||
| 64 | struct IR; | 67 | struct IR; |
| 65 | 68 | ||
| 66 | struct IR_rx { | 69 | struct IR_rx { |
| @@ -941,7 +944,14 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) | |||
| 941 | schedule(); | 944 | schedule(); |
| 942 | set_current_state(TASK_INTERRUPTIBLE); | 945 | set_current_state(TASK_INTERRUPTIBLE); |
| 943 | } else { | 946 | } else { |
| 944 | unsigned char buf[rbuf->chunk_size]; | 947 | unsigned char buf[MAX_XFER_SIZE]; |
| 948 | |||
| 949 | if (rbuf->chunk_size > sizeof(buf)) { | ||
| 950 | zilog_error("chunk_size is too big (%d)!\n", | ||
| 951 | rbuf->chunk_size); | ||
| 952 | ret = -EINVAL; | ||
| 953 | break; | ||
| 954 | } | ||
| 945 | m = lirc_buffer_read(rbuf, buf); | 955 | m = lirc_buffer_read(rbuf, buf); |
| 946 | if (m == rbuf->chunk_size) { | 956 | if (m == rbuf->chunk_size) { |
| 947 | ret = copy_to_user((void *)outbuf+written, buf, | 957 | ret = copy_to_user((void *)outbuf+written, buf, |
