[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20061108124121.GE14871@localhost>
Date: Wed, 8 Nov 2006 21:41:21 +0900
From: Akinobu Mita <akinobu.mita@...il.com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 4/4] input: change to GFP_KERNEL for SERIO_REGISTER_DRIVER event allocation
This patch changes allocation from GFP_ATOMIC to GFP_KERNEL for
SERIO_REGISTER_DRIVER events to make it more robust.
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
Signed-off-by: Akinobu Mita <akinobu.mita@...il.com>
drivers/input/serio/serio.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
Index: work-fault-inject/drivers/input/serio/serio.c
===================================================================
--- work-fault-inject.orig/drivers/input/serio/serio.c
+++ work-fault-inject/drivers/input/serio/serio.c
@@ -191,12 +191,15 @@ static DECLARE_WAIT_QUEUE_HEAD(serio_wai
static struct task_struct *serio_task;
static int serio_queue_event(void *object, struct module *owner,
- enum serio_event_type event_type)
+ enum serio_event_type event_type, gfp_t gfp_flags)
{
unsigned long flags;
struct serio_event *event;
+ struct serio_event *new_event;
int err = 0;
+ new_event = kmalloc(sizeof(struct serio_event), gfp_flags);
+
spin_lock_irqsave(&serio_event_lock, flags);
/*
@@ -208,25 +211,27 @@ static int serio_queue_event(void *objec
*/
list_for_each_entry_reverse(event, &serio_event_list, node) {
if (event->object == object) {
- if (event->type == event_type)
+ if (event->type == event_type) {
+ kfree(new_event);
goto out;
+ }
break;
}
}
- if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) {
+ if (new_event) {
if (!try_module_get(owner)) {
err = -EINVAL;
printk(KERN_WARNING "serio: Can't get module reference, dropping event %d\n", event_type);
- kfree(event);
+ kfree(new_event);
goto out;
}
- event->type = event_type;
- event->object = object;
- event->owner = owner;
+ new_event->type = event_type;
+ new_event->object = object;
+ new_event->owner = owner;
- list_add_tail(&event->node, &serio_event_list);
+ list_add_tail(&new_event->node, &serio_event_list);
wake_up(&serio_wait);
} else {
err = -ENOMEM;
@@ -679,12 +684,12 @@ static void serio_disconnect_port(struct
void serio_rescan(struct serio *serio)
{
- serio_queue_event(serio, NULL, SERIO_RESCAN);
+ serio_queue_event(serio, NULL, SERIO_RESCAN, GFP_ATOMIC);
}
void serio_reconnect(struct serio *serio)
{
- serio_queue_event(serio, NULL, SERIO_RECONNECT);
+ serio_queue_event(serio, NULL, SERIO_RECONNECT, GFP_ATOMIC);
}
/*
@@ -694,7 +699,7 @@ void serio_reconnect(struct serio *serio
void __serio_register_port(struct serio *serio, struct module *owner)
{
serio_init_port(serio);
- serio_queue_event(serio, owner, SERIO_REGISTER_PORT);
+ serio_queue_event(serio, owner, SERIO_REGISTER_PORT, GFP_ATOMIC);
}
/*
@@ -728,7 +733,7 @@ void serio_unregister_child_port(struct
*/
void __serio_unregister_port_delayed(struct serio *serio, struct module *owner)
{
- serio_queue_event(serio, owner, SERIO_UNREGISTER_PORT);
+ serio_queue_event(serio, owner, SERIO_UNREGISTER_PORT, GFP_ATOMIC);
}
@@ -812,7 +817,7 @@ int __serio_register_driver(struct serio
{
drv->driver.bus = &serio_bus;
- return serio_queue_event(drv, owner, SERIO_REGISTER_DRIVER);
+ return serio_queue_event(drv, owner, SERIO_REGISTER_DRIVER, GFP_KERNEL);
}
void serio_unregister_driver(struct serio_driver *drv)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists