Skip to contentSkip to conversation

char:ipmi: Free ipmi_recv_msg messages from the linked list,recv_msgs for the function,ipmi_release in the file,ipmi_devintf.c

PATCH RESEND Corey Minyard 3 participants 4 messages Jan 22, 2015 – Jan 23, 2015 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Patch is queued for 3.20. Thanks.

-corey

Quoted 35 lines · Nicholas Krause

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.

---
 drivers/char/ipmi/ipmi_devintf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/char/ipmi/ipmi_devintf.c +4 -3
index ec318bf..d2af38a 100644
@@ -157,14 +157,15 @@ 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;
 }
 
#2 lore raw
Quoted 1 line · Corey Minyard

Patch is queued for 3.20. Thanks.

That patch is horribly broken.

Thanks,
Sasha

Quoted 45 lines

-corey

Quoted 25 lines · Nicholas Krause

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.

---
 drivers/char/ipmi/ipmi_devintf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/char/ipmi/ipmi_devintf.c +1 -0
index ec318bf..d2af38a 100644
@@ -157,14 +157,15 @@ 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;

drivers/char/ipmi/ipmi_devintf.c static int ipmi_release(struct inode *inode, struct file *file) · line 171

Quoted 10 lines
drivers/char/ipmi/ipmi_devintf.c +3 -3
 
-	/* 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;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
In reply to Corey Minyard
Quoted 1 line · Corey Minyard

Patch is queued for 3.20. Thanks.

That patch is horribly broken.

Thanks,
Sasha

Quoted 45 lines

-corey

Quoted 25 lines · Nicholas Krause

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.

---
 drivers/char/ipmi/ipmi_devintf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/char/ipmi/ipmi_devintf.c +1 -0
index ec318bf..d2af38a 100644
@@ -157,14 +157,15 @@ 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;

drivers/char/ipmi/ipmi_devintf.c static int ipmi_release(struct inode *inode, struct file *file) · line 171

Quoted 10 lines
drivers/char/ipmi/ipmi_devintf.c +3 -3
 
-	/* 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;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 4 lines · nick

Sasha,
How is this patch broken? It builds and clearly frees the list entries. Please explain how to me. Nick

Oh, it does not free priv. That code should not have been removed.

-corey

Quoted 53 lines · Sasha Levin
Quoted 52 lines · Corey Minyard
Quoted 1 line

Patch is queued for 3.20. Thanks.

That patch is horribly broken.

Thanks,
Sasha

Quoted 44 lines

-corey

Quoted 25 lines · Nicholas Krause

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.

---
 drivers/char/ipmi/ipmi_devintf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/char/ipmi/ipmi_devintf.c +1 -0
index ec318bf..d2af38a 100644
@@ -157,14 +157,15 @@ 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;

drivers/char/ipmi/ipmi_devintf.c static int ipmi_release(struct inode *inode, struct file *file) · line 171

Quoted 10 lines
drivers/char/ipmi/ipmi_devintf.c +3 -3
 
-	/* 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;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/