diff mbox series

ca8210: Fix crash by zero initializing data

Message ID 20221121002201.1339636-1-hauke@hauke-m.de (mailing list archive)
State Accepted
Headers show
Series ca8210: Fix crash by zero initializing data | expand

Commit Message

Hauke Mehrtens Nov. 21, 2022, 12:22 a.m. UTC
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>
---
 drivers/net/ieee802154/ca8210.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Schmidt Nov. 29, 2022, 2 p.m. UTC | #1
Hello.

On 21.11.22 01:22, Hauke Mehrtens wrote:
> 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>
> ---
>   drivers/net/ieee802154/ca8210.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index 450b16ad40a4..e1a569b99e4a 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -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;
>   

This patch has been applied to the wpan tree and will be
part of the next pull request to net. Thanks!

regards
Stefan Schmidt
diff mbox series

Patch

diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index 450b16ad40a4..e1a569b99e4a 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -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;