tty: fix bug - kernel can't be pinged through when bootargs console=null
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
@@ -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
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_driveris NULL before callkref_get()intty_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
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_driveris NULL before callkref_get()intty_driver_kref_get().Signed-off-by Sonic Zhang <[email protected]>Signed-off-by Bryan Wu <[email protected]>--- include/linux/tty_driver.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)include/linux/tty_driver.h +0
-0
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 :(
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.