Skip to content

Commit

Permalink
mei: client: use sizeof of variable instead of struct type
Browse files Browse the repository at this point in the history
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: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20200723145927.882743-5-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tomas Winkler authored and Greg Kroah-Hartman committed Jul 23, 2020
1 parent 71ae525 commit 4b40b22
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/misc/mei/client.c
Original file line number Diff line number Diff line change
@@ -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
*/

Expand Down Expand Up @@ -369,7 +369,7 @@ static struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl,
{
struct mei_cl_cb *cb;

cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
cb = kzalloc(sizeof(*cb), GFP_KERNEL);
if (!cb)
return NULL;

Expand Down Expand Up @@ -552,7 +552,7 @@ int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp)
*/
static void mei_cl_init(struct mei_cl *cl, struct mei_device *dev)
{
memset(cl, 0, sizeof(struct mei_cl));
memset(cl, 0, sizeof(*cl));
init_waitqueue_head(&cl->wait);
init_waitqueue_head(&cl->rx_wait);
init_waitqueue_head(&cl->tx_wait);
Expand All @@ -575,7 +575,7 @@ struct mei_cl *mei_cl_allocate(struct mei_device *dev)
{
struct mei_cl *cl;

cl = kmalloc(sizeof(struct mei_cl), GFP_KERNEL);
cl = kmalloc(sizeof(*cl), GFP_KERNEL);
if (!cl)
return NULL;

Expand Down

0 comments on commit 4b40b22

Please sign in to comment.