diff options
author | Nicholas Krause <xerofoify@gmail.com> | 2015-01-31 00:17:54 -0500 |
---|---|---|
committer | Corey Minyard <cminyard@mvista.com> | 2015-02-19 21:58:40 -0500 |
commit | bdf2829cb673afc3aeb4f04531546c7605e8d94e (patch) | |
tree | 4ab83da8ee48cda6bf48916cdc4e448d2f718dc1 /drivers/char/ipmi/ipmi_devintf.c | |
parent | 191cc41405188780e5f8f3c90d84a1e747d962e9 (diff) |
ipmi: Free ipmi_recv_msg messages from the linked list on close
This adds a loop through the elements in the linked list, recv_msgs using
list_for_entry_safe in order to free messages in this list. In addition
we are using the safe version of this marco in order to prevent use after
bugs related to deleting the element we are on currently by holding a
pointer to the next element after the current one we are on and freeing
with the function, ipmi_free_recv_msg internally in this loop.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char/ipmi/ipmi_devintf.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_devintf.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index ec318bf434a6..1786574536b2 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c | |||
@@ -157,12 +157,16 @@ static int ipmi_release(struct inode *inode, struct file *file) | |||
157 | { | 157 | { |
158 | struct ipmi_file_private *priv = file->private_data; | 158 | struct ipmi_file_private *priv = file->private_data; |
159 | int rv; | 159 | int rv; |
160 | struct ipmi_recv_msg *msg, *next; | ||
160 | 161 | ||
161 | rv = ipmi_destroy_user(priv->user); | 162 | rv = ipmi_destroy_user(priv->user); |
162 | if (rv) | 163 | if (rv) |
163 | return rv; | 164 | return rv; |
164 | 165 | ||
165 | /* FIXME - free the messages in the list. */ | 166 | list_for_each_entry_safe(msg, next, &priv->recv_msgs, link) |
167 | ipmi_free_recv_msg(msg); | ||
168 | |||
169 | |||
166 | kfree(priv); | 170 | kfree(priv); |
167 | 171 | ||
168 | return 0; | 172 | return 0; |