Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8284295ybi; Thu, 6 Jun 2019 09:34:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqP3MgCw55+sXvp9hRxGArPm5W/gunGl6FsxqV20NyHvQnle/yDIg/0tDlQxsAcdnTWLsp X-Received: by 2002:a17:902:8ec7:: with SMTP id x7mr10392823plo.50.1559838887585; Thu, 06 Jun 2019 09:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559838887; cv=none; d=google.com; s=arc-20160816; b=D0yo1RpOumOpvCsGDQpHH0bGfrJ6hh2fnLTCu2aicAQL9tQO4qEB6/ZdrNMU5X619M uVYVVno1GKQw3NVuIUVZMzXI7eBGpH144rBoHuyFtZDLnK/iJOt6VOZ3y3iqpQyVp4kg MHaCEVX7OZopf286C74WmGDS5hUCwpiYTfhzg9xYHqFu8kXOvmCT1lc3mvxeXC65rpD5 wQlgDEnPSrexZ3Nsw617CkkbzQKA56BLiP7avL0tF3batv0x8Yryz4SIkvGI596ZUpLn nZsjG/KWaV3F9JvUdE6Uc3F7XUBUbdiLf+jSkJ/F53g3hxPrjtW83IhTizmH0cmBUQlZ HbMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=df2vRYDR/52AmUMfhOIxW5yoeJTer5Z62MUV4qM62eU=; b=Gez/R3HWWUQv5UeQMwyLh8Hxo8yPN3mNUYBXgH++0lJeIiVaV2/r2BFmPVlciilW8T 11gJPgVj5joA4MgKMuOvfDuNlRzPSwhdvhEIp8D50O3OEJFk4o052gt887DT8VTJLCku 9+ONmgf3i8JLOOIxbQ9zEAxVykfTtUaOIjjE50UN87WXVp6Vah1QHUEwhPW6I23Cy++w dq2mo3kyCm+dnK8Dx2v0ckTXbnPltzx3fdNf2Xv+IS7GJek6p2h9ljpcJTrkwz7zNjhv Hff7TavARpaugsB1LBmiBOrAjaNZPyrJOTCrhWQRbQlKFBpNz83E574v0j/WdAGm0wBh ehWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f69si2350329pjg.43.2019.06.06.09.34.31; Thu, 06 Jun 2019 09:34:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727692AbfFFLr7 (ORCPT + 99 others); Thu, 6 Jun 2019 07:47:59 -0400 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:42595 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727263AbfFFLr7 (ORCPT ); Thu, 6 Jun 2019 07:47:59 -0400 Received: from [192.168.2.10] ([46.9.252.75]) by smtp-cloud7.xs4all.net with ESMTPA id Yqs5hzKus3qlsYqs9hmPS4; Thu, 06 Jun 2019 13:47:57 +0200 Subject: Re: [PATCH 4.19 262/276] media: saa7146: avoid high stack usage with clang To: Pavel Machek , pavel@ucw.cz Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Nick Desaulniers , Mauro Carvalho Chehab , Sasha Levin References: <20190530030523.133519668@linuxfoundation.org> <20190530030541.589347419@linuxfoundation.org> <20190606114439.GA27432@amd> From: Hans Verkuil Message-ID: Date: Thu, 6 Jun 2019 13:47:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190606114439.GA27432@amd> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfGNkpSF/LKKl1EbbPpwSZeOpmJU0JtjvAbuHp6TgtAdbfxHvD6hn+AThWsvmkBlX4TM+9M4209YgjqIwIUcsgws2qI97mXfJUR3xkzoo6WNNyxG+Ywx3 qaT3UZB6nROWXMS9A9FOPN1P2bxs8Qf0+yeo1MJrIs1CcAKOhs5go0w70kZWoFH8o28TzEBJF6BaXje3jwpg2eOTSUSNtVvPNMuli8SgM/PXS8q/Fvox7kA9 c0wXeSAMYeQMGX5u6OYws8xpSX811a4+vnRlX7faCzxvGOXe9b0DCYk8uwgEbOWQKtWOYGLU3Hf+E4cjz44qol0FCv7blPr0dltqW/KaQLx86iVuAriINQRZ fTm0gstz Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/6/19 1:44 PM, Pavel Machek wrote: > Hi! > >> Two saa7146/hexium files contain a construct that causes a warning >> when built with clang: >> >> drivers/media/pci/saa7146/hexium_orion.c:210:12: error: stack frame size of 2272 bytes in function 'hexium_probe' >> [-Werror,-Wframe-larger-than=] >> static int hexium_probe(struct saa7146_dev *dev) >> ^ >> drivers/media/pci/saa7146/hexium_gemini.c:257:12: error: stack frame size of 2304 bytes in function 'hexium_attach' >> [-Werror,-Wframe-larger-than=] >> static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info) >> ^ >> >> This one happens regardless of KASAN, and the problem is that a >> constructor to initialize a dynamically allocated structure leads >> to a copy of that structure on the stack, whereas gcc initializes >> it in place. >> >> Link: https://bugs.llvm.org/show_bug.cgi?id=40776 > >> --- a/drivers/media/pci/saa7146/hexium_gemini.c >> +++ b/drivers/media/pci/saa7146/hexium_gemini.c >> @@ -270,9 +270,8 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d >> /* enable i2c-port pins */ >> saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26)); >> >> - hexium->i2c_adapter = (struct i2c_adapter) { >> - .name = "hexium gemini", >> - }; >> + strscpy(hexium->i2c_adapter.name, "hexium gemini", >> + sizeof(hexium->i2c_adapter.name)); >> saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480); >> if (i2c_add_adapter(&hexium->i2c_adapter) < 0) { >> DEB_S("cannot register i2c-device. skipping.\n"); > > As a sideeffect, this removes zero-initialization from > hexium->i2c_adapter. > > Is that intended / correct? It's correct, the hexium struct that contains the i2c_adapter is zeroed with kzalloc, so there is no need to zero it again. Regards, Hans > > [I tried looked at saa7146_i2c_adapter_prepare(), and that does not > initialize all the fields, either.] > > Best regards, > Pavel >