Commit c614970e authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: hw: use sizeof of variable instead of struct type

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@kernel.org>
Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20200723145927.882743-6-tomas.winkler@intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4b40b225
// SPDX-License-Identifier: GPL-2.0 // 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 * Intel Management Engine Interface (Intel MEI) Linux driver
*/ */
...@@ -1600,8 +1600,7 @@ struct mei_device *mei_me_dev_init(struct device *parent, ...@@ -1600,8 +1600,7 @@ struct mei_device *mei_me_dev_init(struct device *parent,
struct mei_me_hw *hw; struct mei_me_hw *hw;
int i; int i;
dev = devm_kzalloc(parent, sizeof(struct mei_device) + dev = devm_kzalloc(parent, sizeof(*dev) + sizeof(*hw), GFP_KERNEL);
sizeof(struct mei_me_hw), GFP_KERNEL);
if (!dev) if (!dev)
return NULL; return NULL;
......
// SPDX-License-Identifier: GPL-2.0 // 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 * Intel Management Engine Interface (Intel MEI) Linux driver
*/ */
...@@ -1201,8 +1201,7 @@ struct mei_device *mei_txe_dev_init(struct pci_dev *pdev) ...@@ -1201,8 +1201,7 @@ struct mei_device *mei_txe_dev_init(struct pci_dev *pdev)
struct mei_device *dev; struct mei_device *dev;
struct mei_txe_hw *hw; struct mei_txe_hw *hw;
dev = devm_kzalloc(&pdev->dev, sizeof(struct mei_device) + dev = devm_kzalloc(&pdev->dev, sizeof(*dev) + sizeof(*hw), GFP_KERNEL);
sizeof(struct mei_txe_hw), GFP_KERNEL);
if (!dev) if (!dev)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment