Re: zr36120 2.6.x port (was: Re: [Mjpeg-users] DC30+ can't capture size greater than 224x168)

From: Christoph Hellwig
Date: Thu Sep 25 2003 - 11:11:53 EST


On Thu, Sep 25, 2003 at 05:59:44PM +0200, Ronald Bultje wrote:
> + if (!try_module_get(THIS_MODULE)) {
> + printk(KERN_ERR "failed to acquire lock on myself\n");
> + return -EIO;
> + }

This is broken, you need an owner outside the open routine.

> +
> + /* find the device */
> + for (i = 0; i < zoran_cards; i++) {
> + if (zorans[i].video_dev->minor == minor) {
> + ztv = &zorans[i];
> + break;
> + }
> + }

What serializes this?

> + if (ztv->have_decoder &&
> + !try_module_get(ztv->decoder->driver->owner)) {
> + printk(KERN_ERR "Failed to acquire lock on TV decoder\n");
> + module_put(THIS_MODULE);
> + return -EIO;
> + }
> + if (ztv->have_tuner &&
> + !try_module_get(ztv->tuner->driver->owner)) {
> + printk(KERN_ERR "Failed to acquire lock on TV tuner\n");
> + if (ztv->have_decoder)
> + module_put(ztv->decoder->driver->owner);
> + module_put(THIS_MODULE);
> + return -EIO;
> + }

You probably want to add a few gotos to unwind at the end of the
function with less code deuplication..

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/