ca8210: Fix crash by zero initializing data
authorHauke Mehrtens <hauke@hauke-m.de>
Mon, 21 Nov 2022 00:22:01 +0000 (01:22 +0100)
committerStefan Schmidt <stefan@datenfreihafen.org>
Tue, 29 Nov 2022 13:56:05 +0000 (14:56 +0100)
The struct cas_control embeds multiple generic SPI structures and we
have to make sure these structures are initialized to default values.
This driver does not set all attributes. When using kmalloc before some
attributes were not initialized and contained random data which caused
random crashes at bootup.

Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Link: https://lore.kernel.org/r/20221121002201.1339636-1-hauke@hauke-m.de
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
drivers/net/ieee802154/ca8210.c

index 450b16a..e1a569b 100644 (file)
@@ -885,7 +885,7 @@ static int ca8210_spi_transfer(
 
        dev_dbg(&spi->dev, "%s called\n", __func__);
 
-       cas_ctl = kmalloc(sizeof(*cas_ctl), GFP_ATOMIC);
+       cas_ctl = kzalloc(sizeof(*cas_ctl), GFP_ATOMIC);
        if (!cas_ctl)
                return -ENOMEM;