Commit eff3b634 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Linus Torvalds

[PATCH] uml: fix net_kern workqueue abuse

Fix up the work on stack and exit scope trouble by placing the work_struct
in the uml_net_private data.
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ffd22b8e
...@@ -72,9 +72,11 @@ static int uml_net_rx(struct net_device *dev) ...@@ -72,9 +72,11 @@ static int uml_net_rx(struct net_device *dev)
return pkt_len; return pkt_len;
} }
static void uml_dev_close(void* dev) static void uml_dev_close(struct work_struct *work)
{ {
dev_close( (struct net_device *) dev); struct uml_net_private *lp =
container_of(work, struct uml_net_private, work);
dev_close(lp->dev);
} }
irqreturn_t uml_net_interrupt(int irq, void *dev_id) irqreturn_t uml_net_interrupt(int irq, void *dev_id)
...@@ -89,7 +91,6 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id) ...@@ -89,7 +91,6 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
spin_lock(&lp->lock); spin_lock(&lp->lock);
while((err = uml_net_rx(dev)) > 0) ; while((err = uml_net_rx(dev)) > 0) ;
if(err < 0) { if(err < 0) {
DECLARE_WORK(close_work, uml_dev_close, dev);
printk(KERN_ERR printk(KERN_ERR
"Device '%s' read returned %d, shutting it down\n", "Device '%s' read returned %d, shutting it down\n",
dev->name, err); dev->name, err);
...@@ -97,9 +98,10 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id) ...@@ -97,9 +98,10 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
* again lp->lock. * again lp->lock.
* And dev_close() can be safely called multiple times on the * And dev_close() can be safely called multiple times on the
* same device, since it tests for (dev->flags & IFF_UP). So * same device, since it tests for (dev->flags & IFF_UP). So
* there's no harm in delaying the device shutdown. */ * there's no harm in delaying the device shutdown.
schedule_work(&close_work); * Furthermore, the workqueue will not re-enqueue an already
#error this is not permitted - close_work will go out of scope * enqueued work item. */
schedule_work(&lp->work);
goto out; goto out;
} }
reactivate_fd(lp->fd, UM_ETH_IRQ); reactivate_fd(lp->fd, UM_ETH_IRQ);
...@@ -365,6 +367,7 @@ static int eth_configure(int n, void *init, char *mac, ...@@ -365,6 +367,7 @@ static int eth_configure(int n, void *init, char *mac,
/* This points to the transport private data. It's still clear, but we /* This points to the transport private data. It's still clear, but we
* must memset it to 0 *now*. Let's help the drivers. */ * must memset it to 0 *now*. Let's help the drivers. */
memset(lp, 0, size); memset(lp, 0, size);
INIT_WORK(&lp->work, uml_dev_close);
/* sysfs register */ /* sysfs register */
if (!driver_registered) { if (!driver_registered) {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/workqueue.h>
struct uml_net { struct uml_net {
struct list_head list; struct list_head list;
...@@ -26,6 +27,7 @@ struct uml_net_private { ...@@ -26,6 +27,7 @@ struct uml_net_private {
struct net_device *dev; struct net_device *dev;
struct timer_list tl; struct timer_list tl;
struct net_device_stats stats; struct net_device_stats stats;
struct work_struct work;
int fd; int fd;
unsigned char mac[ETH_ALEN]; unsigned char mac[ETH_ALEN];
unsigned short (*protocol)(struct sk_buff *); unsigned short (*protocol)(struct sk_buff *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment