aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2014-02-17 08:13:22 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-18 13:05:07 -0500
commita27a76d3c07de08a0d0d298b6bc280c5b820e997 (patch)
tree35189df75481fe1422219ec453723548bed60680 /drivers/misc
parent64092858acfd995fae0def466126692423c30828 (diff)
mei: fix potential read outside of array bounds
Drop not-very-useful check and with this fix read on index that can be after array end. Cleanup search function as byproduct. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.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/client.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 8afba0534779..539e861abc1e 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -29,20 +29,21 @@
29 * mei_me_cl_by_uuid - locate index of me client 29 * mei_me_cl_by_uuid - locate index of me client
30 * 30 *
31 * @dev: mei device 31 * @dev: mei device
32 *
33 * Locking: called under "dev->device_lock" lock
34 *
32 * returns me client index or -ENOENT if not found 35 * returns me client index or -ENOENT if not found
33 */ 36 */
34int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid) 37int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
35{ 38{
36 int i, res = -ENOENT; 39 int i;
37 40
38 for (i = 0; i < dev->me_clients_num; ++i) 41 for (i = 0; i < dev->me_clients_num; ++i)
39 if (uuid_le_cmp(*uuid, 42 if (uuid_le_cmp(*uuid,
40 dev->me_clients[i].props.protocol_name) == 0) { 43 dev->me_clients[i].props.protocol_name) == 0)
41 res = i; 44 return i;
42 break;
43 }
44 45
45 return res; 46 return -ENOENT;
46} 47}
47 48
48 49
@@ -60,16 +61,12 @@ int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
60int mei_me_cl_by_id(struct mei_device *dev, u8 client_id) 61int mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
61{ 62{
62 int i; 63 int i;
64
63 for (i = 0; i < dev->me_clients_num; i++) 65 for (i = 0; i < dev->me_clients_num; i++)
64 if (dev->me_clients[i].client_id == client_id) 66 if (dev->me_clients[i].client_id == client_id)
65 break; 67 return i;
66 if (WARN_ON(dev->me_clients[i].client_id != client_id))
67 return -ENOENT;
68 68
69 if (i == dev->me_clients_num) 69 return -ENOENT;
70 return -ENOENT;
71
72 return i;
73} 70}
74 71
75 72