2005-03-10 12:09:32

by JustMan

[permalink] [raw]
Subject: [PATCH 2.6.11] fix: drivers/base/class.c

fix: drivers/base/class.c

Signed-off-by: Serge A. Suchkov <[email protected]>

diff -uNrp linux/drivers/base/class.orig.c linux/drivers/base/class.c
--- linux/drivers/base/class.orig.c 2005-03-10 12:19:00.000000000 +0300
+++ linux/drivers/base/class.c 2005-03-10 13:59:27.000000000 +0300
@@ -307,12 +307,14 @@ static int class_hotplug(struct kset *ks
if (class_dev->dev) {
/* add physical device, backing this device */
struct device *dev = class_dev->dev;
- char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);

- add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
- &length, "PHYSDEVPATH=%s", path);
- kfree(path);
+ if(kobject_name(&dev->kobj)) {
+ char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);

+ add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
+ &length, "PHYSDEVPATH=%s", path);
+ kfree(path);
+ }
/* add bus name of physical device */
if (dev->bus)
add_hotplug_env_var(envp, num_envp, &i,

--
Regards, JustMan.


2005-03-10 16:55:38

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] fix: drivers/base/class.c

On Thu, Mar 10, 2005 at 03:08:56PM +0300, JustMan wrote:
> fix: drivers/base/class.c

"fix" how? What are you fixing?

> diff -uNrp linux/drivers/base/class.orig.c linux/drivers/base/class.c
> --- linux/drivers/base/class.orig.c 2005-03-10 12:19:00.000000000 +0300
> +++ linux/drivers/base/class.c 2005-03-10 13:59:27.000000000 +0300
> @@ -307,12 +307,14 @@ static int class_hotplug(struct kset *ks
> if (class_dev->dev) {
> /* add physical device, backing this device */
> struct device *dev = class_dev->dev;

Your email client ate all of the tabs, this patch can't be applied :(

> - char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
>
> - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
> - &length, "PHYSDEVPATH=%s", path);
> - kfree(path);
> + if(kobject_name(&dev->kobj)) {
> + char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
>
> + add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
> + &length, "PHYSDEVPATH=%s", path);
> + kfree(path);
> + }

Let me guess, you are using an out-of-tree driver that incorrectly sets
up the kobject and the hotplug userspace code doesn't like the <NULL> in
the strings?

Fix the driver, the kobject should have a name.

thanks,

greg k-h

2005-03-11 05:39:21

by JustMan

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] fix: drivers/base/class.c

> > fix: drivers/base/class.c
>
> "fix" how? What are you fixing?

I'm sorry. Previous subject was "[PATCH 2.6.11] fix call kobject_get_path() with zero kobject argument in drivers/base/class.c"

> > diff -uNrp linux/drivers/base/class.orig.c linux/drivers/base/class.c
> > --- linux/drivers/base/class.orig.c 2005-03-10 12:19:00.000000000 +0300
> > +++ linux/drivers/base/class.c 2005-03-10 13:59:27.000000000 +0300
> > @@ -307,12 +307,14 @@ static int class_hotplug(struct kset *ks
> > if (class_dev->dev) {
> > /* add physical device, backing this device */
> > struct device *dev = class_dev->dev;
>
> Your email client ate all of the tabs, this patch can't be applied :(

oops :(

I send patch as attachment.

>
> Let me guess, you are using an out-of-tree driver that incorrectly sets
> up the kobject

I use standard cdc_acm driver from 2.6.11 for Motorola C350 mobile phone build-in GPRS modem (USB).

In the function (see devices/usb/class/cdc-acm.c):

static void acm_tty_close(struct tty_struct *tty, struct file *filp)
{
struct acm *acm = tty->driver_data;

if (!acm || !acm->used)
return;

down(&open_sem);
if (!--acm->used) {
if (acm->dev) {
acm_set_control(acm, acm->ctrlout = 0);
usb_kill_urb(acm->ctrlurb);
usb_kill_urb(acm->writeurb);
usb_kill_urb(acm->readurb);
} else {
----->
Problem, take place here:
tty_unregister_device(acm_tty_driver, acm->minor);
------>
acm_table[acm->minor] = NULL;
usb_free_urb(acm->ctrlurb);
usb_free_urb(acm->readurb);
usb_free_urb(acm->writeurb);
kfree(acm);
}
}
up(&open_sem);
}


> and the hotplug userspace code doesn't like the <NULL> in
> the strings?

When I unplug my mobile phone (or my phone lost GPRS network) , I have OOPS:

Mar 6 00:55:52 toshiba kernel: <6>usb 2-1: USB disconnect, address 4
Mar 6 00:55:53 toshiba kernel: <1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
Mar 6 00:55:53 toshiba kernel: printing eip:
Mar 6 00:55:53 toshiba kernel: c0255299
Mar 6 00:55:53 toshiba kernel: *pde = 00000000
Mar 6 00:55:53 toshiba kernel: Oops: 0000 [#1]
Mar 6 00:55:53 toshiba kernel: PREEMPT
Mar 6 00:55:53 toshiba kernel: Modules linked in: ppp_deflate zlib_deflate bsd_comp ppp_async crc_ccitt ppp_generic slhc i
pt_REJECT ipt_LOG iptable_filter ipt_MASQUERADE iptable_nat ip_conntrack ip_tables pktcdvd snd_pcm_oss snd_mixer_oss rtc pcs
pkr usbhid intel_agp intelfb uhci_hcd ehci_hcd i8xx_tco 8250_pci 8250 serial_core snd_intel8x0m eepro100 mii evdev pcmcia ye
nta_socket rsrc_nonstatic pcmcia_core nls_koi8_r ntfs cdc_acm usb_storage usbkbd usbmouse usbcore msr cpuid sg sd_mod scsi_m
od dummy ide_cd cdrom snd_intel8x0 snd_ac97_codec snd_pcm snd_timer snd soundcore snd_page_alloc agpgart
Mar 6 00:55:53 toshiba kernel: CPU: 0
Mar 6 00:55:53 toshiba kernel: EIP: 0060:[<c0255299>] Not tainted VLI
Mar 6 00:55:53 toshiba kernel: EFLAGS: 00010246 (2.6.11)
Mar 6 00:55:53 toshiba kernel: EIP is at get_kobj_path_length+0x29/0x50
Mar 6 00:55:53 toshiba kernel: eax: 00000000 ebx: 00000000 ecx: ffffffff edx: ffffffff
Mar 6 00:55:53 toshiba kernel: esi: 00000001 edi: 00000000 ebp: d4397d9c esp: d4397d8c
Mar 6 00:55:53 toshiba kernel: ds: 007b es: 007b ss: 0068
Mar 6 00:55:53 toshiba kernel: Process pppd (pid: 6057, threadinfo=d4396000 task=d432da20)
Mar 6 00:55:53 toshiba kernel: Stack: dedf5bb8 000000d0 dedf5b94 d6dfa298 d4397db8 c0255339 d4397dc4 dedf5bb8
Mar 6 00:55:53 toshiba kernel: c041f708 dedf5b94 d6dfa298 d4397dfc c02bc68f 00000286 ffffffff fffffffd
Mar 6 00:55:53 toshiba kernel: ffffffff 21ac27d7 de53d829 c039d8ab c041f720 00000000 d6dfa90c 00000000
Mar 6 00:55:53 toshiba kernel: Call Trace:
Mar 6 00:55:53 toshiba kernel: [<c0103e3a>] show_stack+0x7a/0x90
Mar 6 00:55:53 toshiba kernel: [<c0103fb9>] show_registers+0x149/0x1b0
Mar 6 00:55:53 toshiba kernel: [<c01041ad>] die+0xdd/0x170
Mar 6 00:55:53 toshiba kernel: [<c01157aa>] do_page_fault+0x30a/0x65a
Mar 6 00:55:53 toshiba kernel: [<c0103abf>] error_code+0x2b/0x30
Mar 6 00:55:53 toshiba kernel: [<c0255339>] kobject_get_path+0x19/0x60
Mar 6 00:55:53 toshiba kernel: [<c02bc68f>] class_hotplug+0x6f/0x160
Mar 6 00:55:53 toshiba kernel: [<c0255ec4>] kobject_hotplug+0x1b4/0x2c0
Mar 6 00:55:53 toshiba kernel: [<c0255660>] kobject_del+0x10/0x20
Mar 6 00:55:53 toshiba kernel: [<c02bcab2>] class_device_del+0x92/0xc0
Mar 6 00:55:53 toshiba kernel: [<c02bcaeb>] class_device_unregister+0xb/0x20
Mar 6 00:55:53 toshiba kernel: [<dfc795bc>] acm_tty_close+0x14c/0x160 [cdc_acm]
Mar 6 00:55:53 toshiba kernel: [<c029f6a2>] release_dev+0x7f2/0x810
Mar 6 00:55:53 toshiba kernel: [<c029fb12>] tty_release+0x12/0x20
Mar 6 00:55:53 toshiba kernel: [<c0156c9b>] __fput+0x12b/0x140
Mar 6 00:55:53 toshiba kernel: [<c01554cf>] filp_close+0x4f/0x80
Mar 6 00:55:53 toshiba kernel: [<c010300f>] syscall_call+0x7/0xb
Mar 6 00:55:53 toshiba kernel: Code: 00 00 55 ba ff ff ff ff 89 e5 57 56 be 01 00 00 00 53 83 ec 04 31 db 89 45 f0 90 8d b
4 26 00 00 00 00 8b 45 f0 89 d1 8b 38 89 d8 <f2> ae f7 d1 49 8b 45 f0 8d 74 31 01 8b 40 24 89 45 f0 85 c0 75


> Fix the driver, the kobject should have a name.
cdc_acm ?

in additional I attach my ver_linux and .config
>
> thanks,
>
> greg k-h
>
>

--
Regards, JustMan.


Attachments:
(No filename) (5.21 kB)
fix_class_hotplug.diff (898.00 B)
ver_linux (1.45 kB)
config-2.6.11 (37.83 kB)
Download all attachments