Re: /sys/devices/system/timer registered twice

Kay Sievers
2004-11-10T02:25:44Z

On Tue, Nov 09, 2004 at 11:39:47AM -0800, Greg KH wrote:
> On Tue, Nov 09, 2004 at 08:30:43PM +0100, Kay Sievers wrote:
> > Hi,
> > I got this on a Centrino box with the latest bk:
> >
> > [kay@pim linux.kay]$ ls -l /sys/devices/system/
> > total 0
> > drwxr-xr-x 7 root root 0 Nov 8 15:12 .
> > drwxr-xr-x 5 root root 0 Nov 8 15:12 ..
> > drwxr-xr-x 3 root root 0 Nov 8 15:12 cpu
> > drwxr-xr-x 3 root root 0 Nov 8 15:12 i8259
> > drwxr-xr-x 2 root root 0 Nov 8 15:12 ioapic
> > drwxr-xr-x 3 root root 0 Nov 8 15:12 irqrouter
> > ?--------- ? ? ? ? ? timer
> >
> >
> > It is caused by registering two devices with the name "timer" from:
> >
> > arch/i386/kernel/time.c
> > arch/i386/kernel/timers/timer_pit.c
> >
> > If I change one of the names, I get two correct looking sysfs entries.
> >
> > Greg, shouldn't the driver core prevent the corruption of the first
> > device if another one tries to register with the same name?
>
> Yes, we should handle this. Can you try the patch below? I just sent
> it to Linus, as it fixes a bug that was recently introduced.
>
> The second registration should fail, and this patch will make it fail,
> and recover properly.

Yes, the registration fails. But it seems that the second call to
create_dir(kobj) with a kobject with the same name and parent corrupts
the dentry from the first call.

To test it, I just called create_dir(kobj) a second time for my video
driver and the sysfs entry of the successful registered kobject was
corrupted:

[kay@pim ~]$ ls -la /sys/class/video4linux/
total 0
drwxr-xr-x 3 root root 0 Nov 10 02:53 .
drwxr-xr-x 18 root root 0 Nov 10 02:53 ..
?--------- ? ? ? ? ? video0

Thanks,
Kay