Re: [PATCH] 2.5.68-bk1 crash in devfs_remove() for defpts files

Pavel Roskin
2003-04-21T21:33:26Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 385 bytes --]

On Mon, 21 Apr 2003, Christoph Hellwig wrote:

> And you are sure you have the following line in pty.c:
>
> pts_driver[i].flags |= TTY_DRIVER_NO_DEVFS;

Yes, it's in drivers/char/pty.c, line 458.

The complete diff between the clean source and my current tree is
attached.

I have forced another rebuild, but the problem with disappearing /dev/pts
persists.

--
Regards,
Pavel Roskin

[-- Attachment #2: Type: TEXT/PLAIN, Size: 2973 bytes --]

--- linux.orig/drivers/char/pty.c
+++ linux/drivers/char/pty.c
@@ -448,17 +448,14 @@ int __init pty_init(void)
init_waitqueue_head(&ptm_state[i][j].open_wait);

pts_driver[i] = pty_slave_driver;
-#ifdef CONFIG_DEVFS_FS
- pts_driver[i].name = "pts/%d";
-#else
pts_driver[i].name = "pts";
-#endif
pts_driver[i].proc_entry = 0;
pts_driver[i].major = UNIX98_PTY_SLAVE_MAJOR+i;
pts_driver[i].minor_start = 0;
pts_driver[i].name_base = i*NR_PTYS;
pts_driver[i].num = ptm_driver[i].num;
pts_driver[i].other = &ptm_driver[i];
+ pts_driver[i].flags |= TTY_DRIVER_NO_DEVFS;
pts_driver[i].table = pts_table[i];
pts_driver[i].termios = pts_termios[i];
pts_driver[i].termios_locked = pts_termios_locked[i];
--- linux.orig/drivers/char/tty_io.c
+++ linux/drivers/char/tty_io.c
@@ -2173,9 +2173,9 @@ int tty_register_driver(struct tty_drive

list_add(&driver->tty_drivers, &tty_drivers);

- if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) {
- for(i = 0; i < driver->num; i++)
- tty_register_device(driver, driver->minor_start + i);
+ if (!(driver->flags & TTY_DRIVER_NO_DEVFS)) {
+ for (i = 0; i < driver->num; i++)
+ tty_register_device(driver, driver->minor_start + i);
}
proc_tty_register_driver(driver);
return error;
@@ -2215,7 +2215,8 @@ int tty_unregister_driver(struct tty_dri
driver->termios_locked[i] = NULL;
kfree(tp);
}
- tty_unregister_device(driver, driver->minor_start + i);
+ if (!(driver->flags & TTY_DRIVER_NO_DEVFS))
+ tty_unregister_device(driver, driver->minor_start + i);
}
proc_tty_unregister_driver(driver);
return 0;
--- linux.orig/drivers/pcmcia/rsrc_mgr.c
+++ linux/drivers/pcmcia/rsrc_mgr.c
@@ -499,14 +499,16 @@ void validate_mem(socket_info_t *s)

void validate_mem(socket_info_t *s)
{
- resource_map_t *m;
+ resource_map_t *m, *n;
static int done = 0;

if (probe_mem && done++ == 0) {
down(&rsrc_sem);
- for (m = mem_db.next; m != &mem_db; m = m->next)
+ for (m = mem_db.next; m != &mem_db; m = n) {
+ n = m->next;
if (do_mem_probe(m->base, m->num, s))
break;
+ }
up(&rsrc_sem);
}
}
--- linux.orig/fs/devfs/base.c
+++ linux/fs/devfs/base.c
@@ -1757,6 +1757,12 @@ void devfs_remove(const char *fmt, ...)
if (n < 64 && buf[0]) {
devfs_handle_t de = _devfs_find_entry(NULL, buf, 0);

+ if (!de) {
+ printk(KERN_WARNING "%s: no entry for %s!\n",
+ __FUNCTION__, buf);
+ return;
+ }
+
write_lock(&de->parent->u.dir.lock);
_devfs_unregister(de->parent, de);
devfs_put(de);
--- linux.orig/fs/partitions/devfs.c
+++ linux/fs/partitions/devfs.c
@@ -81,7 +81,7 @@ void devfs_add_partitioned(struct gendis
{
char dirname[64], symlink[16];

- if (disk->devfs_name[0] != '\0')
+ if (disk->devfs_name[0] == '\0')
sprintf(disk->devfs_name, "%s/disc%d", disk->disk_name,
disk->first_minor >> disk->minor_shift);