aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2014-05-07 09:51:28 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-27 17:15:25 -0400
commit84b3294a40c87e5c8bdaf05d9d3c3aff7e320453 (patch)
tree176459ec36a5cee9959b8303214860d187218db5
parentddb09754e6c7239e302c7b675df9bbd415f8de5d (diff)
mei: fix memory leak of mei_clients array
we never freed the mei_clients array on driver shutdown only on reset add mei_hbm_reset function that wraps the hbm cleanup Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/mei/hbm.c46
-rw-r--r--drivers/misc/mei/hbm.h1
-rw-r--r--drivers/misc/mei/init.c2
3 files changed, 31 insertions, 18 deletions
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index b9a4bb5921f1..804106209d76 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -60,6 +60,34 @@ static int mei_cl_conn_status_to_errno(enum mei_cl_connect_status status)
60} 60}
61 61
62/** 62/**
63 * mei_hbm_idle - set hbm to idle state
64 *
65 * @dev: the device structure
66 */
67void mei_hbm_idle(struct mei_device *dev)
68{
69 dev->init_clients_timer = 0;
70 dev->hbm_state = MEI_HBM_IDLE;
71}
72
73/**
74 * mei_hbm_reset - reset hbm counters and book keeping data structurs
75 *
76 * @dev: the device structure
77 */
78void mei_hbm_reset(struct mei_device *dev)
79{
80 dev->me_clients_num = 0;
81 dev->me_client_presentation_num = 0;
82 dev->me_client_index = 0;
83
84 kfree(dev->me_clients);
85 dev->me_clients = NULL;
86
87 mei_hbm_idle(dev);
88}
89
90/**
63 * mei_hbm_me_cl_allocate - allocates storage for me clients 91 * mei_hbm_me_cl_allocate - allocates storage for me clients
64 * 92 *
65 * @dev: the device structure 93 * @dev: the device structure
@@ -71,9 +99,7 @@ static int mei_hbm_me_cl_allocate(struct mei_device *dev)
71 struct mei_me_client *clients; 99 struct mei_me_client *clients;
72 int b; 100 int b;
73 101
74 dev->me_clients_num = 0; 102 mei_hbm_reset(dev);
75 dev->me_client_presentation_num = 0;
76 dev->me_client_index = 0;
77 103
78 /* count how many ME clients we have */ 104 /* count how many ME clients we have */
79 for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX) 105 for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX)
@@ -82,9 +108,6 @@ static int mei_hbm_me_cl_allocate(struct mei_device *dev)
82 if (dev->me_clients_num == 0) 108 if (dev->me_clients_num == 0)
83 return 0; 109 return 0;
84 110
85 kfree(dev->me_clients);
86 dev->me_clients = NULL;
87
88 dev_dbg(&dev->pdev->dev, "memory allocation for ME clients size=%ld.\n", 111 dev_dbg(&dev->pdev->dev, "memory allocation for ME clients size=%ld.\n",
89 dev->me_clients_num * sizeof(struct mei_me_client)); 112 dev->me_clients_num * sizeof(struct mei_me_client));
90 /* allocate storage for ME clients representation */ 113 /* allocate storage for ME clients representation */
@@ -135,17 +158,6 @@ bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
135} 158}
136 159
137 160
138/**
139 * mei_hbm_idle - set hbm to idle state
140 *
141 * @dev: the device structure
142 */
143void mei_hbm_idle(struct mei_device *dev)
144{
145 dev->init_clients_timer = 0;
146 dev->hbm_state = MEI_HBM_IDLE;
147}
148
149int mei_hbm_start_wait(struct mei_device *dev) 161int mei_hbm_start_wait(struct mei_device *dev)
150{ 162{
151 int ret; 163 int ret;
diff --git a/drivers/misc/mei/hbm.h b/drivers/misc/mei/hbm.h
index 8e39cee408d0..683eb2835cec 100644
--- a/drivers/misc/mei/hbm.h
+++ b/drivers/misc/mei/hbm.h
@@ -50,6 +50,7 @@ static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
50} 50}
51 51
52void mei_hbm_idle(struct mei_device *dev); 52void mei_hbm_idle(struct mei_device *dev);
53void mei_hbm_reset(struct mei_device *dev);
53int mei_hbm_start_req(struct mei_device *dev); 54int mei_hbm_start_req(struct mei_device *dev);
54int mei_hbm_start_wait(struct mei_device *dev); 55int mei_hbm_start_wait(struct mei_device *dev);
55int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl); 56int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl);
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index b3f70eb17934..510f378b1f06 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -122,8 +122,8 @@ int mei_reset(struct mei_device *dev)
122 mei_amthif_reset_params(dev); 122 mei_amthif_reset_params(dev);
123 } 123 }
124 124
125 mei_hbm_reset(dev);
125 126
126 dev->me_clients_num = 0;
127 dev->rd_msg_hdr = 0; 127 dev->rd_msg_hdr = 0;
128 dev->wd_pending = false; 128 dev->wd_pending = false;
129 129