From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-cys01nam02on0114.outbound.protection.outlook.com ([104.47.37.114]:27244 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032471AbeCAPgC (ORCPT ); Thu, 1 Mar 2018 10:36:02 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Arnd Bergmann , Mauro Carvalho Chehab , Sasha Levin Subject: [added to the 4.1 stable tree] media: r820t: fix r820t_write_reg for KASAN Date: Thu, 1 Mar 2018 15:26:36 +0000 Message-ID: <20180301152116.1486-381-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Arnd Bergmann This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 16c3ada89cff9a8c2a0eea34ffa1aa20af3f6008 ] 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=3Dframe-larger-than=3D] 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=3D81715 Signed-off-by: Arnd Bergmann Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/tuners/r820t.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index 71159a58860f..4bfd64b0c0ad 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -410,9 +410,11 @@ static int r820t_write(struct r820t_priv *priv, u8 reg= , const u8 *val, return 0; } =20 -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 =3D val; /* work around GCC PR81715 with asan-stack=3D1 */ + + return r820t_write(priv, reg, &tmp, 1); } =20 static int r820t_read_cache_reg(struct r820t_priv *priv, int reg) @@ -425,17 +427,18 @@ static int r820t_read_cache_reg(struct r820t_priv *pr= iv, int reg) return -EINVAL; } =20 -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 =3D val; int rc =3D r820t_read_cache_reg(priv, reg); =20 if (rc < 0) return rc; =20 - val =3D (rc & ~bit_mask) | (val & bit_mask); + tmp =3D (rc & ~bit_mask) | (tmp & bit_mask); =20 - return r820t_write(priv, reg, &val, 1); + return r820t_write(priv, reg, &tmp, 1); } =20 static int r820t_read(struct r820t_priv *priv, u8 reg, u8 *val, int len) --=20 2.14.1