From patchwork Thu Nov 30 11:08:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10084617 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 30E64602B9 for ; Thu, 30 Nov 2017 11:10:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B50E29F37 for ; Thu, 30 Nov 2017 11:10:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 100B029F3B; Thu, 30 Nov 2017 11:10:20 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 BFE8C29F37 for ; Thu, 30 Nov 2017 11:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750903AbdK3LKG (ORCPT ); Thu, 30 Nov 2017 06:10:06 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:56146 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750771AbdK3LKF (ORCPT ); Thu, 30 Nov 2017 06:10:05 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MDHpc-1eLS8S3VzI-00Gb8p; Thu, 30 Nov 2017 12:10:00 +0100 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH, RESEND 2/2] r820t: fix r820t_write_reg for KASAN Date: Thu, 30 Nov 2017 12:08:05 +0100 Message-Id: <20171130110939.1140969-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171130110939.1140969-1-arnd@arndb.de> References: <20171130110939.1140969-1-arnd@arndb.de> X-Provags-ID: V03:K0:Tzb1FToCWC8G4t4rf+YqzmTwvcDZ69nPXSv5nmTAqpYWGY+wgOT h5N79c2SQ1FHkHYBH/wM965ISfg8n6G2xgyhT0iV81TsGSR934JeA2ozDtGEjwV3r3cYv76 3MKaTGqRzOoj08yDwN2tmyipH7/PUtbUXNdxMWdW/2O0ucm3FLyYesFfDlPtXU+lEi7K4Qh NWdaNbnQmDkENJrpXZDOA== X-UI-Out-Filterresults: notjunk:1; V01:K0:ccrSvec2jVo=:RwoW8MFnEzHGHGFCl+GEZN z6DkoGRixIz5tjnZIctodEDx0iV31ckvKRX69dbGFuV0RkX/pRV1klxvRm9B0h0HpoQlzDrHN tNtMQH/41FX7H3fmt6tQnfYaInEUhM2lid07FISgQSF+sIZ4QTbmls61daawgFNgAlxZq6V7i G4TpqMokOHIp8PKwyFXEpzPAmRppmX42hk0+nxqG2+hOaHkW8EbJmXnpVFvYDzKuM8LGf72+e cTjKdufcS/8Hb5O40uiRWi5M75lWtM6S+OZVqTCU/lHWQ6v9mY6LXb9OrqeXr9SIcyxjzQoeT z7t2K1S70gG6pJvL3BQODtukEqks6ZYA9ykZ9LwCiJjDdAx3hxjNP+SJhXkt9PRGUh3oBzoja QM9OPQ/57K3WE5uXvzSY7k5Ei6K5Sxn9aFdtpOQr492cLtH5dhsoAc53ndS9hobHRsHf36jW2 /SDLo+fPGuR8DtNCbyx+77kUjfpUx6zUTfD9o9nxxu0Oh8q6X5K1zEKkJDCMkMQkSZvrjujwM fsvJKSD/JsUL8OGOtZII3sTY0a5qCIREmtbM3Zy4y/SroVix9xd1xfNmBI6FdCPj+qfBpR74n 3OzGRnQ7myM1U4Vu9nc3XQCwOiD1IDAiI/KRMiS3CW26hSBlk5Mnxr//pc1f0pg1wDXoc6dX2 1XfpNTqzv2FRd6i0J7d3tEJuQ93tAJXDABfpS3xB/vejT6Co3j3L4eCvn+VyV46s/8V+nMFUK UnzCSPXnzmRVxDj18eO6yKFsW0sQAsaBYJ8DXQ== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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)