Re: Freeing a dynamic struct cdev

From: James C. Georgas
Date: Sat Aug 06 2005 - 21:53:29 EST


Ok, I really blew it with that last post:

>
> cdev_add() calls:
> kobj_map()
> kobject_get() [indirectly]
>

This is wrong. When I first looked at it, I saw:

cdev_add() -> kobj_map() -> exact_lock() -> cdev_get() -> kobject_get()

but exact_lock() isn't called here; it is only passed as a function
pointer to kobj_map(), and so calling cdev_add() does /not/ increment
the reference count of the struct cdev.

I guess what threw me for a loop here was that I was expecting separate
functions: one to undo cdev_add() and one to undo cdev_alloc(), but
cdev_del() accomplishes both tasks in one function, with the
kobj_unmap() part having no effect, if the cdev is not mapped at the
time of the call.

--
James C. Georgas <jgeorgas@xxxxxxxxxx>

-
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/