mirror of https://gitee.com/openkylin/linux.git
[media] av7110_hw: 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/pci/ttpci/av7110_hw.c:510:1: warning: 'av7110_fw_cmd' uses dynamic stack allocation [enabled by default] Instead, let's enforce a limit for the buffer. In the specific case of this driver, the maximum fw command size is 6 + 2, as checked using: $ git grep -A1 av7110_fw_cmd drivers/media/pci/ttpci/ So, use 8 for the buffer size. 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>
This commit is contained in:
parent
f7a35df15b
commit
5bf30b3bc4
|
@ -40,6 +40,14 @@
|
|||
|
||||
#define _NOHANDSHAKE
|
||||
|
||||
/*
|
||||
* Max transfer size done by av7110_fw_cmd()
|
||||
*
|
||||
* The maximum size passed to this function is 6 bytes. The buffer also
|
||||
* uses two additional ones for type and size. So, 8 bytes is enough.
|
||||
*/
|
||||
#define MAX_XFER_SIZE 8
|
||||
|
||||
/****************************************************************************
|
||||
* DEBI functions
|
||||
****************************************************************************/
|
||||
|
@ -488,11 +496,18 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
|
|||
int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
|
||||
{
|
||||
va_list args;
|
||||
u16 buf[num + 2];
|
||||
u16 buf[MAX_XFER_SIZE];
|
||||
int i, ret;
|
||||
|
||||
// dprintk(4, "%p\n", av7110);
|
||||
|
||||
if (2 + num > sizeof(buf)) {
|
||||
printk(KERN_WARNING
|
||||
"%s: %s len=%d is too big!\n",
|
||||
KBUILD_MODNAME, __func__, num);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf[0] = ((type << 8) | com);
|
||||
buf[1] = num;
|
||||
|
||||
|
|
Loading…
Reference in New Issue