]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
media: saa7146: avoid high stack usage with clang
authorArnd Bergmann <arnd@arndb.de>
Tue, 19 Feb 2019 17:01:56 +0000 (12:01 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit 03aa4f191a36f33fce015387f84efa0eee94408e ]

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
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fix checkpatch warnings]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/media/pci/saa7146/hexium_gemini.c
drivers/media/pci/saa7146/hexium_orion.c

index d31a2d4494d1a8c20778db9c7cd0496309dbabf9..659c4e88ce0c92e7254c78a44e69e37022c65993 100644 (file)
@@ -269,9 +269,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");
index 043318aa19e2e82f5878786903d4f88ead3ad3d4..67a8d14ff78ddec447eac9768e16a7db28f7cad8 100644 (file)
@@ -230,9 +230,8 @@ static int hexium_probe(struct saa7146_dev *dev)
        saa7146_write(dev, DD1_STREAM_B, 0x00000000);
        saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
 
-       hexium->i2c_adapter = (struct i2c_adapter) {
-               .name = "hexium orion",
-       };
+       strscpy(hexium->i2c_adapter.name, "hexium orion",
+               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");