aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/mei/main.c')
-rw-r--r--drivers/misc/mei/main.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 092330208869..b0903bd44bf7 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -393,10 +393,9 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
393 393
394 if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) { 394 if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) {
395 /* Do not allow to read watchdog client */ 395 /* Do not allow to read watchdog client */
396 i = mei_find_me_client_index(dev, mei_wd_guid); 396 i = mei_me_cl_by_uuid(dev, &mei_wd_guid);
397 if (i >= 0) { 397 if (i >= 0) {
398 struct mei_me_client *me_client = &dev->me_clients[i]; 398 struct mei_me_client *me_client = &dev->me_clients[i];
399
400 if (cl->me_client_id == me_client->client_id) { 399 if (cl->me_client_id == me_client->client_id) {
401 rets = -EBADF; 400 rets = -EBADF;
402 goto out; 401 goto out;
@@ -620,22 +619,12 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
620 rets = -ENODEV; 619 rets = -ENODEV;
621 goto unlock_dev; 620 goto unlock_dev;
622 } 621 }
623 for (i = 0; i < dev->me_clients_num; i++) { 622 i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id);
624 if (dev->me_clients[i].client_id == 623 if (i < 0) {
625 dev->iamthif_cl.me_client_id)
626 break;
627 }
628
629 if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
630 rets = -ENODEV; 624 rets = -ENODEV;
631 goto unlock_dev; 625 goto unlock_dev;
632 } 626 }
633 if (i == dev->me_clients_num || 627 if (length > dev->me_clients[i].props.max_msg_length ||
634 (dev->me_clients[i].client_id !=
635 dev->iamthif_cl.me_client_id)) {
636 rets = -ENODEV;
637 goto unlock_dev;
638 } else if (length > dev->me_clients[i].props.max_msg_length ||
639 length <= 0) { 628 length <= 0) {
640 rets = -EMSGSIZE; 629 rets = -EMSGSIZE;
641 goto unlock_dev; 630 goto unlock_dev;
@@ -688,16 +677,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
688 cl->me_client_id); 677 cl->me_client_id);
689 goto unlock_dev; 678 goto unlock_dev;
690 } 679 }
691 for (i = 0; i < dev->me_clients_num; i++) { 680 i = mei_me_cl_by_id(dev, cl->me_client_id);
692 if (dev->me_clients[i].client_id == 681 if (i < 0) {
693 cl->me_client_id)
694 break;
695 }
696 if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
697 rets = -ENODEV;
698 goto unlock_dev;
699 }
700 if (i == dev->me_clients_num) {
701 rets = -ENODEV; 682 rets = -ENODEV;
702 goto unlock_dev; 683 goto unlock_dev;
703 } 684 }