lkml.org 
[lkml]   [2011]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectkernel panic on device removal when using a workqueue and delayed_work
Hi,

with the following simple kernel module, I have a good chance to get a
kernel panic when I unplug the device:


#include <linux/workqueue.h>
#include <linux/usb.h>
#include <linux/module.h>

MODULE_AUTHOR("Nobody");
MODULE_DESCRIPTION("example driver for causing kernel panic");
MODULE_LICENSE("GPL");

static struct delayed_work poll_work;

static void poll(struct work_struct *work)
{
schedule_delayed_work(&poll_work,
msecs_to_jiffies(100));
}

static int test_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
INIT_DELAYED_WORK(&poll_work, poll);
schedule_delayed_work(&poll_work,
msecs_to_jiffies(100));
return 0;
}

static void test_disconnect(struct usb_interface *intf)
{
cancel_delayed_work_sync(&poll_work);
}

static const struct usb_device_id device_table[] = {
{USB_DEVICE(0x1234, 0x5678)},
{}
};

MODULE_DEVICE_TABLE(usb, device_table);

static struct usb_driver test_driver = {
.name = "test",
.id_table = device_table,
.probe = test_probe,
.disconnect = test_disconnect,
};

static int __init test_mod_init(void)
{
return usb_register(&test_driver);
}

static void __exit test_mod_exit(void)
{
usb_deregister(&test_driver);
}

module_init(test_mod_init);
module_exit(test_mod_exit);




A picture of the backtrace (the machine immediately turns off without
saving a backtrace) can be found at

http://imageshack.us/photo/my-images/823/img075gv.jpg

Kernel version is 3.1.0.


This is the first time I'm using a workqueue, so there is a good chance
that I missed something...
Or is this a kernel bug ?


Regards,
Frank Schaefer



\
 
 \ /
  Last update: 2011-10-30 20:21    [W:0.056 / U:45.452 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site