Skip to contentSkip to conversation

serial: fixup /proc/tty/driver/serial after proc_fops conversion

DISCUSSION Geert Uytterhoeven 1 participant 1 message Apr 2, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 22 lines · Linux Kernel Mailing List

   serial: fixup /proc/tty/driver/serial after proc_fops conversion

   "struct tty_driver *" lies in m->private not in v which is SEQ_TOKEN_START which is 1 which is enough to trigger NULL dereference next line:

       BUG: unable to handle kernel NULL pointer dereference at 000000ad
       IP: [<c040d689>] uart_proc_show+0xe/0x2b0

   Noticed by Linus.

---
 drivers/serial/serial_core.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/serial/serial_core.c +0 -0
index bf3c0e3..b0bb29d 100644

drivers/serial/serial_core.c static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i) · line 1770

Quoted 7 lines
drivers/serial/serial_core.c +1 -1
@@ -1765,7 +1765,7 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
 
  static int uart_proc_show(struct seq_file *m, void *v)
  {
-       struct tty_driver *ttydrv = v;
+       struct tty_driver *ttydrv = m->private;
        struct uart_driver *drv = ttydrv->driver_state;
        int i;

Yeah, I've been bitten by this one in the past, too. It's very confusing to have a `void *'
parameter in a callback whose registration (proc_create_data()) also takes a `void *'.

What is this `v' parameter actually used for? I couldn't find any users during a quick
(non-exhaustive) search?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds