Skip to contentSkip to conversation

TTY: tty_io, lookup retval fixup

PATCH In review Jiri Slaby 2 participants 3 messages Feb 1, 2009 Char and misc drivers

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 TTY: tty_io, lookup retval fixup

Make sure we fail on NULL return value possibly returned by pty master lookup.

Convert NULL to ERR_PTR(-ENODEV), since NULL is not captured by IS_ERR() in __tty_open.

---
 drivers/char/tty_io.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/char/tty_io.c +2 -1
index ff92099..2c14dd8 100644
@@ -1217,7 +1217,8 @@ static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver,
 	struct tty_struct *tty;
 
 	if (driver->ops->lookup)
-		return driver->ops->lookup(driver, inode, idx);
+		return driver->ops->lookup(driver, inode, idx) ? :
+			ERR_PTR(-ENODEV);
 
 	tty = driver->ttys[idx];
 	return tty;
Signature · 1 line
1.6.1.2
#1 lore raw
Quoted 5 lines · On Sun, 1 Feb 2009 22:39:16 +0100 Jiri Slaby <[email protected]> wrote:

Make sure we fail on NULL return value possibly returned by pty master lookup.

Convert NULL to ERR_PTR(-ENODEV), since NULL is not captured by IS_ERR() in __tty_open.

Better to fix any broken functions I think

author
#2 lore raw

PATCH 1/1 TTY: pty, lookup retval fixup

Make sure we fail on NULL return value possibly returned by master tty lookup.

Convert NULL to ERR_PTR(-ENODEV) in ptm_unix98_lookup, since NULL is not captured by IS_ERR() in __tty_open.

---
 drivers/char/pty.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/pty.c +1 -1
index 31038a0..261223b 100644
@@ -508,7 +508,7 @@ static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver,
 	struct tty_struct *tty = devpts_get_tty(ptm_inode, idx);
 	if (tty)
 		tty = tty->link;
-	return tty;
+	return tty ? : ERR_PTR(-ENODEV);
 }
 
 /**
Signature · 1 line
1.6.1.2