aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-09-02 06:29:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-05 10:13:10 -0400
commitcb4af713f95f049056c25e0c18f652c3338c2bc7 (patch)
tree558b60da77c649ceebc0f92e8296291ecbc8a6ee /drivers/misc/mei
parent81fbb94d1fbdad184ca4091da4cae87a92dbf3c7 (diff)
mei: make me client counters less error prone
commit 1aee351a739153529fbb98ee461777b2abd5e1c9 upstream. 1. u8 counters are prone to hard to detect overflow: make them unsigned long to match bit_ functions argument type 2. don't check me_clients_num for negativity, it is unsigned. 3. init all the me client counters from one place 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/hbm.c10
-rw-r--r--drivers/misc/mei/mei_dev.h6
2 files changed, 9 insertions, 7 deletions
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 6916045166eb..23b5b7bcba9f 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -35,11 +35,15 @@ static void mei_hbm_me_cl_allocate(struct mei_device *dev)
35 struct mei_me_client *clients; 35 struct mei_me_client *clients;
36 int b; 36 int b;
37 37
38 dev->me_clients_num = 0;
39 dev->me_client_presentation_num = 0;
40 dev->me_client_index = 0;
41
38 /* count how many ME clients we have */ 42 /* count how many ME clients we have */
39 for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX) 43 for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX)
40 dev->me_clients_num++; 44 dev->me_clients_num++;
41 45
42 if (dev->me_clients_num <= 0) 46 if (dev->me_clients_num == 0)
43 return; 47 return;
44 48
45 kfree(dev->me_clients); 49 kfree(dev->me_clients);
@@ -221,7 +225,7 @@ static int mei_hbm_prop_req(struct mei_device *dev)
221 struct hbm_props_request *prop_req; 225 struct hbm_props_request *prop_req;
222 const size_t len = sizeof(struct hbm_props_request); 226 const size_t len = sizeof(struct hbm_props_request);
223 unsigned long next_client_index; 227 unsigned long next_client_index;
224 u8 client_num; 228 unsigned long client_num;
225 229
226 230
227 client_num = dev->me_client_presentation_num; 231 client_num = dev->me_client_presentation_num;
@@ -650,8 +654,6 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
650 if (dev->dev_state == MEI_DEV_INIT_CLIENTS && 654 if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
651 dev->hbm_state == MEI_HBM_ENUM_CLIENTS) { 655 dev->hbm_state == MEI_HBM_ENUM_CLIENTS) {
652 dev->init_clients_timer = 0; 656 dev->init_clients_timer = 0;
653 dev->me_client_presentation_num = 0;
654 dev->me_client_index = 0;
655 mei_hbm_me_cl_allocate(dev); 657 mei_hbm_me_cl_allocate(dev);
656 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES; 658 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
657 659
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 4de5140e7379..73c7700aee21 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -402,9 +402,9 @@ struct mei_device {
402 struct mei_me_client *me_clients; /* Note: memory has to be allocated */ 402 struct mei_me_client *me_clients; /* Note: memory has to be allocated */
403 DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX); 403 DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
404 DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX); 404 DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
405 u8 me_clients_num; 405 unsigned long me_clients_num;
406 u8 me_client_presentation_num; 406 unsigned long me_client_presentation_num;
407 u8 me_client_index; 407 unsigned long me_client_index;
408 408
409 struct mei_cl wd_cl; 409 struct mei_cl wd_cl;
410 enum mei_wd_states wd_state; 410 enum mei_wd_states wd_state;