Skip to content

Commit 08e4d04

Browse files
arndbgregkh
authored andcommitted
media: r820t: fix r820t_write_reg for KASAN
commit 16c3ada upstream. With CONFIG_KASAN, we get an overly long stack frame due to inlining the register access functions: drivers/media/tuners/r820t.c: In function 'generic_set_freq.isra.7': drivers/media/tuners/r820t.c:1334:1: error: the frame size of 2880 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] This is caused by a gcc bug that has now been fixed in gcc-8. To work around the problem, we can pass the register data through a local variable that older gcc versions can optimize out as well. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 30c68fb commit 08e4d04

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

drivers/media/tuners/r820t.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,11 @@ static int r820t_write(struct r820t_priv *priv, u8 reg, const u8 *val,
396396
return 0;
397397
}
398398

399-
static int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val)
399+
static inline int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val)
400400
{
401-
return r820t_write(priv, reg, &val, 1);
401+
u8 tmp = val; /* work around GCC PR81715 with asan-stack=1 */
402+
403+
return r820t_write(priv, reg, &tmp, 1);
402404
}
403405

404406
static int r820t_read_cache_reg(struct r820t_priv *priv, int reg)
@@ -411,17 +413,18 @@ static int r820t_read_cache_reg(struct r820t_priv *priv, int reg)
411413
return -EINVAL;
412414
}
413415

414-
static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
416+
static inline int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
415417
u8 bit_mask)
416418
{
419+
u8 tmp = val;
417420
int rc = r820t_read_cache_reg(priv, reg);
418421

419422
if (rc < 0)
420423
return rc;
421424

422-
val = (rc & ~bit_mask) | (val & bit_mask);
425+
tmp = (rc & ~bit_mask) | (tmp & bit_mask);
423426

424-
return r820t_write(priv, reg, &val, 1);
427+
return r820t_write(priv, reg, &tmp, 1);
425428
}
426429

427430
static int r820t_read(struct r820t_priv *priv, u8 reg, u8 *val, int len)

0 commit comments

Comments
 (0)