LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: [PATCHv2] char:ipmi: Free ipmi_recv_msg messages from the linked list,recv_msgs for the function,ipmi_release in the file,ipmi_devintf.c
[not found] ` <54C292A7.9090000@gmail.com>
@ 2015-01-23 19:00 ` Corey Minyard
2015-01-24 1:32 ` Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Corey Minyard @ 2015-01-23 19:00 UTC (permalink / raw)
To: nick; +Cc: openipmi-developer, linux-kernel
On 01/23/2015 12:27 PM, nick wrote:
> Corney,
> Hope this patch fixes the issue. Sorry about missing that kfree
> being required. :(
Well, the kfree needs to be after the free of the messages. You can't
use an item after you free it.
-corey
> Nick
>
>
> On 2015-01-23 01:02 PM, Nicholas Krause wrote:
>> 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>
>> ---
>> drivers/char/ipmi/ipmi_devintf.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
>> index ec318bf..a625510 100644
>> --- a/drivers/char/ipmi/ipmi_devintf.c
>> +++ b/drivers/char/ipmi/ipmi_devintf.c
>> @@ -157,14 +157,19 @@ static int ipmi_release(struct inode *inode, struct file *file)
>> {
>> struct ipmi_file_private *priv = file->private_data;
>> int rv;
>> + struct ipmi_recv_msg *msg, *next;
>>
>> rv = ipmi_destroy_user(priv->user);
>> if (rv)
>> return rv;
>>
>> - /* FIXME - free the messages in the list. */
>> kfree(priv);
>>
>> + list_for_each_entry_safe(msg, next, &priv->recv_msgs, link) {
>> + ipmi_free_recv_msg(msg);
>> + }
>> +
>> +
>> return 0;
>> }
>>
>>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCHv2] char:ipmi: Free ipmi_recv_msg messages from the linked list,recv_msgs for the function,ipmi_release in the file,ipmi_devintf.c
2015-01-23 19:00 ` [PATCHv2] char:ipmi: Free ipmi_recv_msg messages from the linked list,recv_msgs for the function,ipmi_release in the file,ipmi_devintf.c Corey Minyard
@ 2015-01-24 1:32 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2015-01-24 1:32 UTC (permalink / raw)
To: minyard, nick; +Cc: openipmi-developer, linux-kernel
On 01/23/2015 02:00 PM, Corey Minyard wrote:
> On 01/23/2015 12:27 PM, nick wrote:
>> > Corney,
>> > Hope this patch fixes the issue. Sorry about missing that kfree
>> > being required. :(
> Well, the kfree needs to be after the free of the messages. You can't
> use an item after you free it.
As you can see, his patches aren't event tested. See https://lkml.org/lkml/2014/8/4/206 .
Thanks,
Sasha
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-24 1:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1422036143-27808-1-git-send-email-xerofoify@gmail.com>
[not found] ` <54C292A7.9090000@gmail.com>
2015-01-23 19:00 ` [PATCHv2] char:ipmi: Free ipmi_recv_msg messages from the linked list,recv_msgs for the function,ipmi_release in the file,ipmi_devintf.c Corey Minyard
2015-01-24 1:32 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).