Skip to contentSkip to conversation

staging: dgnc: Fix a NULL pointer dereference

PATCH In review Daeseok Youn 2 participants 3 messages May 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: dgnc: Fix a NULL pointer dereference

The error handling for print_drive after calling tty_alloc_driver() was needed. But there was error handling but too late for this. Error handling code moved after tty_alloc_driver() call.

Fixes 60b3109e5e2d ("staging: dgnc: use tty_alloc_driver instead of kcalloc")
---
 drivers/staging/dgnc/dgnc_tty.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +5 -5
index 2cecdb0..392d532 100644
@@ -224,6 +224,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 					     TTY_DRIVER_DYNAMIC_DEV |
 					     TTY_DRIVER_HARDWARE_BREAK);
 
+	if (IS_ERR(brd->print_driver)) {
+		rc = PTR_ERR(brd->print_driver);
+		goto unregister_serial_driver;
+	}
+
 	snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
 
 	brd->print_driver->name = brd->print_name;
@@ -235,11 +240,6 @@ int dgnc_tty_register(struct dgnc_board *brd)
 	brd->print_driver->init_termios = DgncDefaultTermios;
 	brd->print_driver->driver_name = DRVSTR;
 
-	if (IS_ERR(brd->print_driver)) {
-		rc = PTR_ERR(brd->print_driver);
-		goto unregister_serial_driver;
-	}
-
 	/*
 	 * Entry points for driver.  Called by the kernel from
 	 * tty_io.c and n_tty.c.
Signature · 1 line
2.8.2
maintainer
#1 lore raw
Quoted 10 lines · Daeseok Youn

The error handling for print_drive after calling tty_alloc_driver() was needed. But there was error handling but too late for this. Error handling code moved after tty_alloc_driver() call.

Fixes 60b3109e5e2d ("staging: dgnc: use tty_alloc_driver instead of kcalloc")
---
 drivers/staging/dgnc/dgnc_tty.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Patch doesn't apply at all, does it need something else to be merged first?

confused,

greg k-h

maintainer
#2 lore raw
Quoted 12 lines · Greg KH
Quoted 10 lines · Daeseok Youn

The error handling for print_drive after calling tty_alloc_driver() was needed. But there was error handling but too late for this. Error handling code moved after tty_alloc_driver() call.

Fixes 60b3109e5e2d ("staging: dgnc: use tty_alloc_driver instead of kcalloc")
---
 drivers/staging/dgnc/dgnc_tty.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Quoted 2 lines

Patch doesn't apply at all, does it need something else to be merged first?

Oh nevermind, I tried applying it to the wrong git tree, my fault...

I need some sleep...

greg k-h