]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
media: r820t: fix r820t_write_reg for KASAN
authorArnd Bergmann <arnd@arndb.de>
Thu, 30 Nov 2017 11:08:05 +0000 (06:08 -0500)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 23 Feb 2018 14:27:45 +0000 (08:27 -0600)
BugLink: http://bugs.launchpad.net/bugs/1751131
commit 16c3ada89cff9a8c2a0eea34ffa1aa20af3f6008 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>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/media/tuners/r820t.c

index ba80376a3b86465807e284caf3928e71ec206fb8..d097eb04a0e9232d099eb7455765c252efc85621 100644 (file)
@@ -396,9 +396,11 @@ static int r820t_write(struct r820t_priv *priv, u8 reg, const u8 *val,
        return 0;
 }
 
-static int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val)
+static inline int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val)
 {
-       return r820t_write(priv, reg, &val, 1);
+       u8 tmp = val; /* work around GCC PR81715 with asan-stack=1 */
+
+       return r820t_write(priv, reg, &tmp, 1);
 }
 
 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)
                return -EINVAL;
 }
 
-static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
+static inline int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
                                u8 bit_mask)
 {
+       u8 tmp = val;
        int rc = r820t_read_cache_reg(priv, reg);
 
        if (rc < 0)
                return rc;
 
-       val = (rc & ~bit_mask) | (val & bit_mask);
+       tmp = (rc & ~bit_mask) | (tmp & bit_mask);
 
-       return r820t_write(priv, reg, &val, 1);
+       return r820t_write(priv, reg, &tmp, 1);
 }
 
 static int r820t_read(struct r820t_priv *priv, u8 reg, u8 *val, int len)