From ce2927e9a3b325b92acfeab66632f9a38d572722 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Fri, 10 Apr 2015 02:42:30 +0300 Subject: [PATCH] staging: dgnc: don't forget to check if ->channels[i] is NULL in dgnc_tty_uninit() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a check if ->channels[i] is NULL because a NULL pointer may be dereferenced in case one of the allocations failed Reported-by: Dan Carpenter Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index a8c88f829e42..6c9261cb88ec 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -403,7 +403,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd) dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL; brd->dgnc_Serial_Major = 0; for (i = 0; i < brd->nasync; i++) { - dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); + if (brd->channels[i]) + dgnc_remove_tty_sysfs(brd->channels[i]-> + ch_tun.un_sysfs); tty_unregister_device(&brd->SerialDriver, i); } tty_unregister_driver(&brd->SerialDriver); @@ -414,7 +416,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd) dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL; brd->dgnc_TransparentPrint_Major = 0; for (i = 0; i < brd->nasync; i++) { - dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); + if (brd->channels[i]) + dgnc_remove_tty_sysfs(brd->channels[i]-> + ch_pun.un_sysfs); tty_unregister_device(&brd->PrintDriver, i); } tty_unregister_driver(&brd->PrintDriver); -- 2.30.2