Skip to content

Commit b4a6700

Browse files
Tomas Winklergregkh
authored andcommitted
mei: ioctl: use sizeof of variable instead of struct type
Use sizeof(connect_data))) instead of sizeof(struct mei_connect_client_data) when copying data between user space and kernel. 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-3-tomas.winkler@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent df4b37b commit b4a6700

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/misc/mei/main.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Copyright (c) 2003-2018, Intel Corporation. All rights reserved.
3+
* Copyright (c) 2003-2020, Intel Corporation. All rights reserved.
44
* Intel Management Engine Interface (Intel MEI) Linux driver
55
*/
66

@@ -476,7 +476,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
476476
case IOCTL_MEI_CONNECT_CLIENT:
477477
dev_dbg(dev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
478478
if (copy_from_user(&connect_data, (char __user *)data,
479-
sizeof(struct mei_connect_client_data))) {
479+
sizeof(connect_data))) {
480480
dev_dbg(dev->dev, "failed to copy data from userland\n");
481481
rets = -EFAULT;
482482
goto out;
@@ -488,7 +488,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
488488

489489
/* if all is ok, copying the data back to user. */
490490
if (copy_to_user((char __user *)data, &connect_data,
491-
sizeof(struct mei_connect_client_data))) {
491+
sizeof(connect_data))) {
492492
dev_dbg(dev->dev, "failed to copy data to userland\n");
493493
rets = -EFAULT;
494494
goto out;

0 commit comments

Comments
 (0)