aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2014-08-21 07:29:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-24 01:57:48 -0400
commit154eb18fedd5219516887a7e2bf2825b1b06ff2b (patch)
tree4f5c3cb7c1efa79b7ea4f42fdeabd6c1679486c3 /drivers/misc/mei
parent4f046e7b6f4f0d8c9504e22cf8eacfe5c78f0f01 (diff)
mei: use connect_data on the stack
There is no need for dynamic allocation for connect_data. We can use variable on the stack and make code less error prone and simple Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei')
-rw-r--r--drivers/misc/mei/main.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 2f80c77629b0..d60621ef5621 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -433,9 +433,6 @@ static int mei_ioctl_connect_client(struct file *file,
433 int rets; 433 int rets;
434 434
435 cl = file->private_data; 435 cl = file->private_data;
436 if (WARN_ON(!cl || !cl->dev))
437 return -ENODEV;
438
439 dev = cl->dev; 436 dev = cl->dev;
440 437
441 if (dev->dev_state != MEI_DEV_ENABLED) { 438 if (dev->dev_state != MEI_DEV_ENABLED) {
@@ -506,7 +503,6 @@ end:
506 return rets; 503 return rets;
507} 504}
508 505
509
510/** 506/**
511 * mei_ioctl - the IOCTL function 507 * mei_ioctl - the IOCTL function
512 * 508 *
@@ -520,7 +516,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
520{ 516{
521 struct mei_device *dev; 517 struct mei_device *dev;
522 struct mei_cl *cl = file->private_data; 518 struct mei_cl *cl = file->private_data;
523 struct mei_connect_client_data *connect_data = NULL; 519 struct mei_connect_client_data connect_data;
524 int rets; 520 int rets;
525 521
526 522
@@ -540,26 +536,19 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
540 switch (cmd) { 536 switch (cmd) {
541 case IOCTL_MEI_CONNECT_CLIENT: 537 case IOCTL_MEI_CONNECT_CLIENT:
542 dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n"); 538 dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
543 connect_data = kzalloc(sizeof(struct mei_connect_client_data), 539 if (copy_from_user(&connect_data, (char __user *)data,
544 GFP_KERNEL);
545 if (!connect_data) {
546 rets = -ENOMEM;
547 goto out;
548 }
549
550 if (copy_from_user(connect_data, (char __user *)data,
551 sizeof(struct mei_connect_client_data))) { 540 sizeof(struct mei_connect_client_data))) {
552 dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n"); 541 dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
553 rets = -EFAULT; 542 rets = -EFAULT;
554 goto out; 543 goto out;
555 } 544 }
556 545
557 rets = mei_ioctl_connect_client(file, connect_data); 546 rets = mei_ioctl_connect_client(file, &connect_data);
558 if (rets) 547 if (rets)
559 goto out; 548 goto out;
560 549
561 /* if all is ok, copying the data back to user. */ 550 /* if all is ok, copying the data back to user. */
562 if (copy_to_user((char __user *)data, connect_data, 551 if (copy_to_user((char __user *)data, &connect_data,
563 sizeof(struct mei_connect_client_data))) { 552 sizeof(struct mei_connect_client_data))) {
564 dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n"); 553 dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
565 rets = -EFAULT; 554 rets = -EFAULT;
@@ -567,13 +556,13 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
567 } 556 }
568 557
569 break; 558 break;
559
570 default: 560 default:
571 dev_err(&dev->pdev->dev, ": unsupported ioctl %d.\n", cmd); 561 dev_err(&dev->pdev->dev, ": unsupported ioctl %d.\n", cmd);
572 rets = -ENOIOCTLCMD; 562 rets = -ENOIOCTLCMD;
573 } 563 }
574 564
575out: 565out:
576 kfree(connect_data);
577 mutex_unlock(&dev->device_lock); 566 mutex_unlock(&dev->device_lock);
578 return rets; 567 return rets;
579} 568}