Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0ca97b8 authored by Daeseok Youn's avatar Daeseok Youn Committed by Greg Kroah-Hartman
Browse files

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: 60b3109e ("staging: dgnc: use tty_alloc_driver instead of kcalloc")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDaeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d1382968
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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.