Skip to contentSkip to conversation

tty: fix bug - kernel can't be pinged through when bootargs console=null

PATCH In review Bryan Wu 3 participants 4 messages Feb 6, 2009 – Feb 7, 2009 TTY layer and serial drivers

lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

PATCH 1/1 tty: fix bug - kernel can't be pinged through when bootargs console=null

From: Sonic Zhang <[email protected]>

when pass bootargs console=null into kernel from u-boot, the booted up kernel can't be pinged through. This happens after the kernel is upgraded to 2.6.28.

Should check if tty_driver is NULL before call kref_get() in tty_driver_kref_get().

---
 include/linux/tty_driver.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/tty_driver.h +2 -1
index 08e0883..2a602a8 100644
@@ -312,7 +312,8 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
 extern void tty_driver_kref_put(struct tty_driver *driver);
 extern inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
 {
-	kref_get(&d->kref);
+	if (d)
+		kref_get(&d->kref);
 	return d;
 }
 
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 7 lines · On Fri, 6 Feb 2009 16:27:57 +0800 Bryan Wu <[email protected]> wrote:

From: Sonic Zhang <[email protected]>

when pass bootargs console=null into kernel from u-boot, the booted up kernel can't be pinged through. This happens after the kernel is upgraded to 2.6.28.

Should check if tty_driver is NULL before call kref_get() in tty_driver_kref_get().

Should not call tty_driver_kref_get(NULL) in the first place....

Need to fix the real bug not paper over it

#2 lore raw
In reply to Bryan Wu
Quoted 19 lines · On Fri, 6 Feb 2009 16:27:57 +0800 Bryan Wu <[email protected]> wrote:

From: Sonic Zhang <[email protected]>

when pass bootargs console=null into kernel from u-boot, the booted up kernel can't be pinged through. This happens after the kernel is upgraded to 2.6.28.

Should check if tty_driver is NULL before call kref_get() in tty_driver_kref_get().

---
 include/linux/tty_driver.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/tty_driver.h +0 -0
index 08e0883..2a602a8 100644

include/linux/tty_driver.h extern struct tty_driver *tty_find_polling_driver(char *name, int *line); · line 319

Quoted 9 lines
include/linux/tty_driver.h +2 -1
@@ -312,7 +312,8 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
 extern void tty_driver_kref_put(struct tty_driver *driver);
 extern inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
 {
-	kref_get(&d->kref);
+	if (d)
+		kref_get(&d->kref);
 	return d;
 }
 

Did any earlier kernel versions handle this situation OK?

If so, we might need to be back-compatible with buggy userspace :(

#3 lore raw
Quoted 3 lines

Did any earlier kernel versions handle this situation OK?

If so, we might need to be back-compatible with buggy userspace :(

Nothing to do with userspace. You can't call tty_driver_kref_get(NULL), it's completely bogus.