From: fschaefer.oss@googlemail.com (Frank Schäfer)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Workqueue and kernel panic on device disconnect
Date: Wed, 26 Oct 2011 19:07:50 +0200 [thread overview]
Message-ID: <4EA83E66.8030005@googlemail.com> (raw)
In-Reply-To: <4EA72A56.20308@googlemail.com>
Am 25.10.2011 23:29, schrieb Frank Sch?fer:
> Hi,
>
> I'm trying to use a workqueue in a usb driver for polling the states
> of the device buttons.
> That works fine, but when I disconnect the device, the kernel
> sometimes explodes.
> The machine turns off immediately, without saving a backtrace (I will
> try to make a photo tomorrow)
>
> The code:
>
>
>
> static struct delayed_work poll_work;
>
> static const struct usb_device_id device_table[] = {
> {USB_DEVICE(0x1234, 0x5678)},
> {}
> };
>
> static void poll(struct work_struct *work)
> {
> schedule_delayed_work(&poll_work,
> msecs_to_jiffies(100));
> }
>
> MODULE_DEVICE_TABLE(usb, device_table);
>
> 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 struct usb_driver test_driver = {
> .name = MODULE_NAME,
> .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);
>
>
> What am I doing wrong ?
> Is there anything else I have to do in addition to calling
> cancel_delayed_work_sync() in the disconnect fcn ?
>
> Thanks,
> Frank Schaefer
>
I've managed to make a photo of the backtrace:
http://imageshack.us/photo/my-images/823/img075gv.jpg
Could this be a kernel bug ?
Regards,
Frank
prev parent reply other threads:[~2011-10-26 17:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-25 21:29 Workqueue and kernel panic on device disconnect Frank Schäfer
2011-10-26 17:07 ` Frank Schäfer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EA83E66.8030005@googlemail.com \
--to=fschaefer.oss@googlemail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.