Skip to contentSkip to conversation

Fixes for the deferqueue_add() function

PATCH In review Dan Smith 2 participants 3 messages Jun 19, 2009 1 message not in the archive

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 Fixes for the deferqueue_add() function

I'm not sure how the deferqueue would (or has ever) worked without these modifications, but I had to make them in order to use it :)

---
 kernel/deferqueue.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/deferqueue.c +3 -2
index efd99d5..470b8a3 100644
@@ -66,18 +66,19 @@ int deferqueue_add(struct deferqueue_head *head, void *data, int size,
 {
 	struct deferqueue_entry *dq;
 
-	dq = kmalloc(sizeof(dq) + size, GFP_KERNEL);
+	dq = kmalloc(sizeof(*dq) + size, GFP_KERNEL);
 	if (!dq)
 		return -ENOMEM;
 
 	dq->function = func;
 	dq->destructor = dtor;
+	INIT_LIST_HEAD(&dq->list);
 	memcpy(dq->data, data, size);
 
 	pr_debug("%s: adding work %p func %p dtor %p\n",
 		 __func__, dq, func, dtor);
 	spin_lock(&head->lock);
-	list_add_tail(&head->list, &dq->list);
+	list_add_tail(&dq->list, &head->list);
 	spin_unlock(&head->lock);
 	return 0;
 }
Signature · 1 line
1.6.0.4
#2 lore raw
In reply to a message not in the archive
Quoted 14 lines · Dan Smith

I'm not sure how the deferqueue would (or has ever) worked without these modifications, but I had to make them in order to use it :)

---
 kernel/deferqueue.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/deferqueue.c +0 -0
index efd99d5..470b8a3 100644

kernel/deferqueue.c int deferqueue_add(struct deferqueue_head *head, void *data, int size, · line 69

Quoted 5 lines
kernel/deferqueue.c +1 -1
@@ -66,18 +66,19 @@ int deferqueue_add(struct deferqueue_head *head, void *data, int size,
 {
 	struct deferqueue_entry *dq;
 
-	dq = kmalloc(sizeof(dq) + size, GFP_KERNEL);
+	dq = kmalloc(sizeof(*dq) + size, GFP_KERNEL);

huh. yeah.

kernel/deferqueue.c int deferqueue_add(struct deferqueue_head *head, void *data, int size, · line 75

Quoted 6 lines
kernel/deferqueue.c +1 -0
 	if (!dq)
 		return -ENOMEM;
 
 	dq->function = func;
 	dq->destructor = dtor;
+	INIT_LIST_HEAD(&dq->list);

I'm pretty sure only head->list needed to be initialized.

kernel/deferqueue.c int deferqueue_add(struct deferqueue_head *head, void *data, int size, · line 81

Quoted 7 lines
kernel/deferqueue.c +1 -1
 	memcpy(dq->data, data, size);
 
 	pr_debug("%s: adding work %p func %p dtor %p\n",
 		 __func__, dq, func, dtor);
 	spin_lock(&head->lock);
-	list_add_tail(&head->list, &dq->list);
+	list_add_tail(&dq->list, &head->list);

at least after you've done this :)

Quoted 10 lines
kernel/deferqueue.c +0 -0
 	spin_unlock(&head->lock);
 	return 0;
 }
Signature · 6 lines
1.6.0.4

_______________________________________________
Containers mailing list
Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
author
#3 lore raw
Quoted 1 line

kernel/deferqueue.c int deferqueue_add(struct deferqueue_head *head, void *data, int size, · line 75

Quoted 1 line
kernel/deferqueue.c +1 -0
+	INIT_LIST_HEAD(&dq->list);

SH> I'm pretty sure only head->list needed to be initialized.

Quoted 2 lines

kernel/deferqueue.c int deferqueue_add(struct deferqueue_head *head, void *data, int size, · line 81

Quoted 2 lines
kernel/deferqueue.c +1 -1
-	list_add_tail(&head->list, &dq->list);
+	list_add_tail(&dq->list, &head->list);

SH> at least after you've done this :)

Right, right, well, it was part of the process... :)

Signature · 3 lines
Dan Smith
IBM Linux Technology Center
email: danms-r/[email protected]