[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3fa1faf1-40a8-7506-ea93-f266b0e45c86@embeddedor.com>
Date: Thu, 23 Jul 2020 11:53:37 -0500
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Tomas Winkler <tomas.winkler@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Alexander Usyskin <alexander.usyskin@...el.com>,
linux-kernel@...r.kernel.org,
"Gustavo A . R . Silva" <gustavoars@...nel.org>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [char-misc-next 5/6] mei: hw: use sizeof of variable instead of
struct type
On 7/23/20 09:59, Tomas Winkler wrote:
> Use sizeof(*dev) + sizeof(*hw) instead of
> sizeof(struct mei_device) + sizeof(struct mei_me_hw)
>
> There is a possibility of bug when variable type has changed but
> corresponding struct passed to the sizeof has not.
>
> Cc: Gustavo A. R. Silva <gustavoars@...nel.org>
> Signed-off-by: Tomas Winkler <tomas.winkler@...el.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Thanks
--
Gustavo
> ---
> drivers/misc/mei/hw-me.c | 5 ++---
> drivers/misc/mei/hw-txe.c | 5 ++---
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
> index c51d3da8f333..7692b69abcb5 100644
> --- a/drivers/misc/mei/hw-me.c
> +++ b/drivers/misc/mei/hw-me.c
> @@ -1,6 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
> /*
> - * Copyright (c) 2003-2019, Intel Corporation. All rights reserved.
> + * Copyright (c) 2003-2020, Intel Corporation. All rights reserved.
> * Intel Management Engine Interface (Intel MEI) Linux driver
> */
>
> @@ -1600,8 +1600,7 @@ struct mei_device *mei_me_dev_init(struct device *parent,
> struct mei_me_hw *hw;
> int i;
>
> - dev = devm_kzalloc(parent, sizeof(struct mei_device) +
> - sizeof(struct mei_me_hw), GFP_KERNEL);
> + dev = devm_kzalloc(parent, sizeof(*dev) + sizeof(*hw), GFP_KERNEL);
> if (!dev)
> return NULL;
>
> diff --git a/drivers/misc/mei/hw-txe.c b/drivers/misc/mei/hw-txe.c
> index 785b260b3ae9..a4e854b9b9e6 100644
> --- a/drivers/misc/mei/hw-txe.c
> +++ b/drivers/misc/mei/hw-txe.c
> @@ -1,6 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
> /*
> - * Copyright (c) 2013-2019, Intel Corporation. All rights reserved.
> + * Copyright (c) 2013-2020, Intel Corporation. All rights reserved.
> * Intel Management Engine Interface (Intel MEI) Linux driver
> */
>
> @@ -1201,8 +1201,7 @@ struct mei_device *mei_txe_dev_init(struct pci_dev *pdev)
> struct mei_device *dev;
> struct mei_txe_hw *hw;
>
> - dev = devm_kzalloc(&pdev->dev, sizeof(struct mei_device) +
> - sizeof(struct mei_txe_hw), GFP_KERNEL);
> + dev = devm_kzalloc(&pdev->dev, sizeof(*dev) + sizeof(*hw), GFP_KERNEL);
> if (!dev)
> return NULL;
>
>
Powered by blists - more mailing lists