Skip to content

Commit 699112f

Browse files
committed
drm/i2c: tda9950: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this sets the buffer to maximum size and adds a sanity check. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Cc: David Airlie <airlied@linux.ie> Cc: Hans Verkuil <hans.verkuil@cisco.com> Cc: Russell King <rmk+kernel@armlinux.org.uk> Cc: dri-devel@lists.freedesktop.org Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 7daf201 commit 699112f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎drivers/gpu/drm/i2c/tda9950.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ struct tda9950_priv {
7676
static int tda9950_write_range(struct i2c_client *client, u8 addr, u8 *p, int cnt)
7777
{
7878
struct i2c_msg msg;
79-
u8 buf[cnt + 1];
79+
u8 buf[CEC_MAX_MSG_SIZE + 3];
8080
int ret;
8181

82+
if (WARN_ON(cnt > sizeof(buf) - 1))
83+
return -EINVAL;
84+
8285
buf[0] = addr;
8386
memcpy(buf + 1, p, cnt);
8487

0 commit comments

Comments
 (0)