aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-05-07 14:12:31 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-21 12:54:26 -0400
commit46e0cd87d90056383c8b5408fb297f18c1bdddf3 (patch)
treee7dff466e9abd76c37f8dc15b47fd7a0b9b0d457 /drivers/misc
parent221ba151731133c8b0e1cdb9bfd2a45b3ba8764b (diff)
mei: fix out of array access to me clients array
The patch 9f81abdac362: "mei: implement mei_cl_connect function" from Jan 8, 2013, leads to the following static checker warning: "drivers/misc/mei/main.c:522 mei_ioctl_connect_client() warn: check 'dev->me_clients[]' for negative offsets (-2)" Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/main.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 7c44c8dbae42..053139f61086 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -489,11 +489,16 @@ static int mei_ioctl_connect_client(struct file *file,
489 489
490 /* find ME client we're trying to connect to */ 490 /* find ME client we're trying to connect to */
491 i = mei_me_cl_by_uuid(dev, &data->in_client_uuid); 491 i = mei_me_cl_by_uuid(dev, &data->in_client_uuid);
492 if (i >= 0 && !dev->me_clients[i].props.fixed_address) { 492 if (i < 0 || dev->me_clients[i].props.fixed_address) {
493 cl->me_client_id = dev->me_clients[i].client_id; 493 dev_dbg(&dev->pdev->dev, "Cannot connect to FW Client UUID = %pUl\n",
494 cl->state = MEI_FILE_CONNECTING; 494 &data->in_client_uuid);
495 rets = -ENODEV;
496 goto end;
495 } 497 }
496 498
499 cl->me_client_id = dev->me_clients[i].client_id;
500 cl->state = MEI_FILE_CONNECTING;
501
497 dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n", 502 dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
498 cl->me_client_id); 503 cl->me_client_id);
499 dev_dbg(&dev->pdev->dev, "FW Client - Protocol Version = %d\n", 504 dev_dbg(&dev->pdev->dev, "FW Client - Protocol Version = %d\n",
@@ -527,11 +532,6 @@ static int mei_ioctl_connect_client(struct file *file,
527 goto end; 532 goto end;
528 } 533 }
529 534
530 if (cl->state != MEI_FILE_CONNECTING) {
531 rets = -ENODEV;
532 goto end;
533 }
534
535 535
536 /* prepare the output buffer */ 536 /* prepare the output buffer */
537 client = &data->out_client_properties; 537 client = &data->out_client_properties;
@@ -543,7 +543,6 @@ static int mei_ioctl_connect_client(struct file *file,
543 rets = mei_cl_connect(cl, file); 543 rets = mei_cl_connect(cl, file);
544 544
545end: 545end:
546 dev_dbg(&dev->pdev->dev, "free connect cb memory.");
547 return rets; 546 return rets;
548} 547}
549 548