lkml.org 
[lkml]   [2006]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] register sysfs device for lp devices
> > + * can display it in their sysfs nodes */
> > +#define parport_set_dev(port,devptr) ((port)->dev = (devptr))
>
> If you are going to save off a pointer to a structure, you need to
> increment it's reference count. You aren't doing that here, and bad
> things might happen if it gets removed from under you :(

Guess I should think a bit more and copy other code a bit less.
The two examples I looked at were sound and network devices.
While they differ by calling class_device_create more directly,
this does not call a get_device either. (Or where have I missed
it?)

I thought that parport would only exist while the device exists and
is bound to the driver, when that stops it is removed anyway.
But lp.c does not implement lp_detach, so it still keeps this data
and it is really exposed even when the device vanished.

Some unrelated strage behaviour from this: When I manualy unbind
and bind an parport supplier, via
echo -n "id" > /sys/bus/.../drivers/.../unbind
and then echo -n "id" > /sys/bus/.../drivers/.../bind
I get a new lp device every time without the old one vanishing.

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

\
 
 \ /
  Last update: 2006-02-18 14:03    [W:0.082 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site