From patchwork Fri Sep 22 21:29:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9967079 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E21B6057C for ; Fri, 22 Sep 2017 21:31:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3110529A30 for ; Fri, 22 Sep 2017 21:31:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0EA429A52; Fri, 22 Sep 2017 21:31:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 022A529A4E for ; Fri, 22 Sep 2017 21:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679AbdIVVbL (ORCPT ); Fri, 22 Sep 2017 17:31:11 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:62236 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752554AbdIVVbH (ORCPT ); Fri, 22 Sep 2017 17:31:07 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0LvN23-1dDklQ1MEl-010gHN; Fri, 22 Sep 2017 23:30:39 +0200 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , Jiri Pirko , Arend van Spriel , Kalle Valo , "David S. Miller" , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Masahiro Yamada , Michal Marek , Andrew Morton , Kees Cook , Geert Uytterhoeven , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, kasan-dev@googlegroups.com, linux-kbuild@vger.kernel.org, Jakub Jelinek , =?UTF-8?q?Martin=20Li=C5=A1ka?= Subject: [PATCH v4 5/9] r820t: fix r820t_write_reg for KASAN Date: Fri, 22 Sep 2017 23:29:16 +0200 Message-Id: <20170922212930.620249-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170922212930.620249-1-arnd@arndb.de> References: <20170922212930.620249-1-arnd@arndb.de> X-Provags-ID: V03:K0:5UIKjDdx5TPWijAblgwl7fPHNso5cdYP6yvfBUx1aQikrLUEBtt 3JmR6vce6Q/n1qhb+YBZTIXhRk5nRCXm3fSGYj0APAh6OwzjkyZS7S26iyhfOu87R01g8cy Gs13V9lB68QQTivOr71Mp2TYHG+rIgzvCrsmrX82bEKf7UlDI3N0GVEM+XvCuvNPKZldWXA 5u5sYfgDkub4gpPBPxTHQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:pizOdsbHG8E=:w78jKMm6ZA8OuepjiBPngf FKd2F13xMVq4oCHcSvLbZAGbob+tHyPBB/ODXsXJ3nyl0AIIE/OQCfIzzn8TzgKxjYByu8AkT KfxyuFq/isash9U8KaacLU42uuidUWwLixcMxzEsFXjNGvZqBqqUM9IVJnbqiVlbce0qwQOGY fzsvoGpcyuri8zSDq2Ofw74UDxIE45tnBhyJXX89uwjtxVjOBX9N/bIlOurqA1ZfvoENdbTev Fm8yGqwwjbtPjNIMbH9Sx9WMmMTrLVJaDaAv7Puv+mOyBdTSzyv7/C8pf2yJwpU7fqRnINg+o go0OIQ4sQVoFQ0YB7/1jNXuHb50ZlQPmSb0HQXdTF9hblifbJQJ6j96AwpRRLUvmt/0EDsPZW wjU3FGxt6YnoJprccDoSQnfZsyo5z2FY8eVAM2Di4wmR5BB1XlydIQtN3b708YJ8XZDxUy67D CkBkVFI448EIkA1M0v+rIaK5Rk4YtWdvObKd9fzaJLBWmAd/h8MWjKZcYsKSEEV9vo2c78zqe LaUIeX+mOGfIrfhHeKG3aAnu50r3HXIXFKY/H7So4ZdVm2cunI1dYEsnLn8vHH6QGtLq7OvgI u5qZmMuDFme6bhF1YbnvXroYJsUkBXOjfKXLnPazzZ/oqkn8vn2Anc8qR7zNNfTIfadHpbKPN DpUppigC6F0Hry+SI/0wqkSFE0iSKqiS1pOormKAvfdD7/ILlMOYgtFuo1aBsXkLZqczFiXU7 QyWPV3FHRDNkSXEILbXwPnJ62GY/UzSgwqn/Jw== Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 ba80376a3b86..d097eb04a0e9 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -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)