Skip to content

Commit

Permalink
media: lirc_zilog: Don't use dynamic static allocation
Browse files Browse the repository at this point in the history
commit ac5b4b6 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Mauro Carvalho Chehab authored and Greg Kroah-Hartman committed Dec 4, 2013
1 parent 182c128 commit 282e059
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/staging/media/lirc/lirc_zilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
#include <media/lirc_dev.h>
#include <media/lirc.h>

/* Max transfer size done by I2C transfer functions */
#define MAX_XFER_SIZE 64

struct IR;

struct IR_rx {
Expand Down Expand Up @@ -941,7 +944,14 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
schedule();
set_current_state(TASK_INTERRUPTIBLE);
} else {
unsigned char buf[rbuf->chunk_size];
unsigned char buf[MAX_XFER_SIZE];

if (rbuf->chunk_size > sizeof(buf)) {
zilog_error("chunk_size is too big (%d)!\n",
rbuf->chunk_size);
ret = -EINVAL;
break;
}
m = lirc_buffer_read(rbuf, buf);
if (m == rbuf->chunk_size) {
ret = copy_to_user((void *)outbuf+written, buf,
Expand Down

0 comments on commit 282e059

Please sign in to comment.