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>
This commit is contained in:
Nicholas Krause 2015-01-31 00:17:54 -05:00 коммит произвёл Corey Minyard
Родитель 191cc41405
Коммит bdf2829cb6
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -157,12 +157,16 @@ static int ipmi_release(struct inode *inode, struct file *file)
{ {
struct ipmi_file_private *priv = file->private_data; struct ipmi_file_private *priv = file->private_data;
int rv; int rv;
struct ipmi_recv_msg *msg, *next;
rv = ipmi_destroy_user(priv->user); rv = ipmi_destroy_user(priv->user);
if (rv) if (rv)
return rv; return rv;
/* FIXME - free the messages in the list. */ list_for_each_entry_safe(msg, next, &priv->recv_msgs, link)
ipmi_free_recv_msg(msg);
kfree(priv); kfree(priv);
return 0; return 0;