Subject: [PATCH] nethost: Make put_host safe in interrupt context From: Eric W. Biederman Date: 1133990024 -0700 Since the network code via sk_free calls put_host in a interrupt context. Use schedule_work to put us back in process context where the nethost structure can be safely freed. --- include/linux/nethost.h | 2 ++ net/core/host.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletions(-) 160c8403ebdb4b1ec4c10dffb154e383c4da8026 diff --git a/include/linux/nethost.h b/include/linux/nethost.h index 1c55185..0cd135d 100644 --- a/include/linux/nethost.h +++ b/include/linux/nethost.h @@ -6,12 +6,14 @@ #include #include #include +#include struct nethost { atomic_t count; struct new_utsname utsname; #ifdef CONFIG_NET struct net_device loopback_dev; + struct work_struct work; #endif }; diff --git a/net/core/host.c b/net/core/host.c index c275a27..9c8c62d 100644 --- a/net/core/host.c +++ b/net/core/host.c @@ -2,14 +2,23 @@ #include #include #include +#include #include -void __put_host(struct nethost *host) +static void do_put_host(void *arg) { + struct nethost *host = arg; loopback_free(&host->loopback_dev); kfree(host); } +void __put_host(struct nethost *host) +{ + /* Cleanup the host structure in process context */ + INIT_WORK(&host->work, do_put_host, host); + schedule_work(&host->work); +} + int __copy_host(int flags, struct task_struct *p) { struct net_device *dev; -- 1.0.GIT