Re: [OOPS/HACK] atmel_cs and the latest changes in sysfs/symlink.c

Dmitry Torokhov
2004-04-23T13:02:48Z

On Friday 23 April 2004 07:25 am, Marcel Holtmann wrote:
> Hi Dmitry,
>
> > The latest change in sysfs/symlink (conversion to use kobject_name instead
> > of name fiedld directly) broke atmel_cs driver:
> >
> > Apr 23 00:30:10 core kernel: Oops: 0000 [#1]
> > Apr 23 00:30:10 core kernel: PREEMPT
> > Apr 23 00:30:10 core kernel: CPU: 0
> > Apr 23 00:30:10 core kernel: EIP: 0060:[<c0182ef9>] Not tainted
> > Apr 23 00:30:10 core kernel: EFLAGS: 00010246 (2.6.6-rc2)
> > Apr 23 00:30:10 core kernel: EIP is at object_path_length+0x19/0x30
<skip>
> > Apr 23 00:30:10 core kernel: Call Trace:
> > Apr 23 00:30:10 core kernel: [<c0182f99>] sysfs_create_link+0x29/0x140
> > Apr 23 00:30:10 core kernel: [<c01ac578>] kobject_hotplug+0x58/0x60
> > Apr 23 00:30:10 core kernel: [<c0211490>] class_device_dev_link+0x30/0x40
<skip>
> >
> > Below is the "fix" that helps avoid oopsing, and should be removed when
> > atmel_cs driver properly registers atmel_device.
>
> I haven't tested it yet, but the same problem should apply to the
> bt3c_cs driver for the 3Com Bluetooth card. Are there any patches
> available that integrates the PCMCIA subsystem into the driver model, so
> we don't have to hack around it if a firmware download is needed?
>
I do not know. But the problem seems to be somewhat widespread - I just got
oops with the following trace:

[<c0182f99>] sysfs_create_link+0x29/0x140
[<c01ac578>] kobject_hotplug+0x58/0x60
[<c0211490>] class_device_dev_link+0x30/0x40
[<c02117ad>] class_device_add+0xed/0x130
[<e185ffab>] usb_register_dev+0x12b/0x170 [usbcore]
[<e1b2bf2a>] hiddev_connect+0x7a/0x120 [usbhid]

I think we should not oops, just complain loudly, when we come across a
kobject which has never beek kobject_add()ed, like in patch below.

--
Dmitry

===== include/linux/kobject.h 1.26 vs edited =====
--- 1.26/include/linux/kobject.h Thu Mar 11 08:20:22 2004
+++ edited/include/linux/kobject.h Fri Apr 23 07:58:52 2004
@@ -39,6 +39,11 @@

static inline char * kobject_name(struct kobject * kobj)
{
+ if (unlikely(!kobj->k_name)) {
+ printk("kobject_name(): not registered kobject\n");
+ dump_stack();
+ return kobj->name;
+ }
return kobj->k_name;
}