From: Jean-Francois Moine <moinejf@free.fr>
To: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Cc: video4linux-list@redhat.com, v4l-dvb-maintainer@linuxtv.org
Subject: Re: [BUG] zc3xx oopses on unplug: unable to handle kernel paging request
Date: Wed, 19 Nov 2008 11:32:12 +0100 [thread overview]
Message-ID: <1227090732.2998.8.camel@localhost> (raw)
In-Reply-To: <200811182219.38925.m.kozlowski@tuxland.pl>
[-- Attachment #1: Type: text/plain, Size: 902 bytes --]
On Tue, 2008-11-18 at 22:19 +0100, Mariusz Kozlowski wrote:
> and it didn't fix it. It didn't apply cleanly - there
> was some offset during patching if that matters.
[snip]
> If you could provide patches against some mainline kernel versions
> like 2.6.28-rc5 that would be great - and please specify which bits
> exactly should I patch to avoid confusion.
>
> BTW. Can you reproduce the oops I'm seeing?
Hi Mariusz,
You have the oops thanks to poison and it is not enabled in my kernel.
I found the real bug: the device structure was part of the gspca device
and it was freed on close after webcam unplug while streaming.
I join a patch I merged from the linux-2.6.28-rc5 source (not compiled -
the original patch is the last one in my mercurial repository).
Thanks again.
--
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef | http://moinejf.free.fr/
[-- Attachment #2: gspca.patch --]
[-- Type: text/x-patch, Size: 3546 bytes --]
--- linux-2.26.8-rc5/drivers/media/video/gspca/gspca.h.orig 2008-11-19 11:10:11.000000000 +0100
+++ linux-2.26.8-rc5/drivers/media/video/gspca/gspca.h 2008-11-19 11:16:58.000000000 +0100
@@ -120,8 +120,8 @@
};
struct gspca_dev {
- struct video_device vdev; /* !! must be the first item */
- struct file_operations fops;
+ struct video_device *vdev;
+ struct module *module; /* subdriver handling the device */
struct usb_device *dev;
struct kref kref;
struct file *capt_file; /* file doing video capture */
--- linux-2.26.8-rc5/drivers/media/video/gspca/gspca.c.orig 2008-11-19 11:10:02.000000000 +0100
+++ linux-2.26.8-rc5/drivers/media/video/gspca/gspca.c 2008-11-19 11:19:57.000000000 +0100
@@ -863,7 +863,7 @@
int ret;
PDEBUG(D_STREAM, "%s open", current->comm);
- gspca_dev = (struct gspca_dev *) video_devdata(file);
+ gspca_dev = video_drvdata(file);
if (mutex_lock_interruptible(&gspca_dev->queue_lock))
return -ERESTARTSYS;
if (!gspca_dev->present) {
@@ -875,6 +875,13 @@
ret = -EBUSY;
goto out;
}
+
+ /* protect the subdriver against rmmod */
+ if (!try_module_get(gspca_dev->module)) {
+ ret = -ENODEV;
+ goto out;
+ }
+
gspca_dev->users++;
/* one more user */
@@ -884,10 +891,10 @@
#ifdef GSPCA_DEBUG
/* activate the v4l2 debug */
if (gspca_debug & D_V4L2)
- gspca_dev->vdev.debug |= V4L2_DEBUG_IOCTL
+ gspca_dev->vdev->debug |= V4L2_DEBUG_IOCTL
| V4L2_DEBUG_IOCTL_ARG;
else
- gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL
+ gspca_dev->vdev->debug &= ~(V4L2_DEBUG_IOCTL
| V4L2_DEBUG_IOCTL_ARG);
#endif
ret = 0;
@@ -921,6 +928,7 @@
gspca_dev->memory = GSPCA_MEMORY_NO;
}
file->private_data = NULL;
+ module_put(gspca_dev->module);
mutex_unlock(&gspca_dev->queue_lock);
PDEBUG(D_STREAM, "close done");
@@ -1748,11 +1756,6 @@
return ret;
}
-static void dev_release(struct video_device *vfd)
-{
- /* nothing */
-}
-
static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.open = dev_open,
@@ -1800,7 +1803,7 @@
.name = "gspca main driver",
.fops = &dev_fops,
.ioctl_ops = &dev_ioctl_ops,
- .release = dev_release, /* mandatory */
+ .release = video_device_release,
.minor = -1,
};
@@ -1869,17 +1872,18 @@
init_waitqueue_head(&gspca_dev->wq);
/* init video stuff */
- memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template);
- gspca_dev->vdev.parent = &dev->dev;
- memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops);
- gspca_dev->vdev.fops = &gspca_dev->fops;
- gspca_dev->fops.owner = module; /* module protection */
+ gspca_dev->vdev = video_device_alloc();
+ memcpy(gspca_dev->vdev, &gspca_template, sizeof gspca_template);
+ gspca_dev->vdev->parent = &dev->dev;
+ gspca_dev->module = module;
gspca_dev->present = 1;
- ret = video_register_device(&gspca_dev->vdev,
+ video_set_drvdata(gspca_dev->vdev, gspca_dev);
+ ret = video_register_device(gspca_dev->vdev,
VFL_TYPE_GRABBER,
video_nr);
if (ret < 0) {
err("video_register_device err %d", ret);
+ video_device_release(gspca_dev->vdev);
goto out;
}
@@ -1887,7 +1891,8 @@
PDEBUG(D_PROBE, "probe ok");
return 0;
out:
- kref_put(&gspca_dev->kref, gspca_delete);
+ kfree(gspca_dev->usb_buf);
+ kfree(gspca_dev);
return ret;
}
EXPORT_SYMBOL(gspca_dev_probe);
@@ -1905,7 +1910,7 @@
usb_set_intfdata(intf, NULL);
/* We don't want people trying to open up the device */
- video_unregister_device(&gspca_dev->vdev);
+ video_unregister_device(gspca_dev->vdev);
gspca_dev->present = 0;
gspca_dev->streaming = 0;
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
next prev parent reply other threads:[~2008-11-19 10:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-15 11:18 [BUG] zc3xx oopses on unplug: unable to handle kernel paging request Mariusz Kozlowski
2008-11-15 11:18 ` Mariusz Kozlowski
2008-11-15 18:48 ` Jean-Francois Moine
[not found] ` <200811162224.47885.m.kozlowski@tuxland.pl>
2008-11-18 18:57 ` Jean-Francois Moine
[not found] ` <200811182219.38925.m.kozlowski@tuxland.pl>
2008-11-19 10:32 ` Jean-Francois Moine [this message]
2008-11-19 13:52 ` David Ellingsworth
[not found] ` <492439AE.1070903@redhat.com>
2008-11-19 20:20 ` [v4l-dvb-maintainer] " Jean-Francois Moine
[not found] ` <200811192256.09361.m.kozlowski@tuxland.pl>
2008-11-20 18:19 ` Jean-Francois Moine
2008-11-20 18:57 ` David Ellingsworth
2008-11-20 19:03 ` Jean-Francois Moine
2008-11-21 0:24 ` leandro Costantino
2008-11-21 14:54 ` David Ellingsworth
2008-11-21 15:03 ` David Ellingsworth
2008-11-22 12:41 ` Jean-Francois Moine
[not found] ` <200811221421.50818.m.kozlowski@tuxland.pl>
2008-11-23 17:43 ` Jean-Francois Moine
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=1227090732.2998.8.camel@localhost \
--to=moinejf@free.fr \
--cc=m.kozlowski@tuxland.pl \
--cc=v4l-dvb-maintainer@linuxtv.org \
--cc=video4linux-list@redhat.com \
/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.