Re: [PATCH 2.6] Class support for ppdev.c

From: viro
Date: Sat Apr 10 2004 - 15:31:00 EST


On Sat, Apr 10, 2004 at 09:46:01PM +0200, Marcel Sebek wrote:
> And new updated patch. partport_find_number() needs to decrement refcount
> by parport_put_port().

And it's still broken. New parports can appear at any point - hell, we even
have USB->parport converters. IOW, if you want to do something useful here -
use ->attach()/->detach() of parport_driver.

> for (i = 0; i < PARPORT_MAX; i++) {
> - devfs_mk_cdev(MKDEV(PP_MAJOR, i),
> + if ((port = parport_find_number(i))) {
> + class_simple_device_add(ppdev_class, MKDEV(PP_MAJOR, i),
> + NULL, "parport%d", i);
> + parport_put_port(port);
> + }
> + err = devfs_mk_cdev(MKDEV(PP_MAJOR, i),
> S_IFCHR | S_IRUGO | S_IWUGO, "parports/%d", i);
> + if (err)
> + goto out_class;
> }
>
> printk (KERN_INFO PP_VERSION "\n");
> - return 0;
> + goto out;
> +
> +out_class:
> + for (i = 0; i < PARPORT_MAX; i++)
> + class_simple_device_remove(MKDEV(PP_MAJOR, i));


*raised brows*

So you are freeing the stuff you've never allocated? Cute...
-
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/