From: Bill Pemberton Date: Tue, 9 Oct 2012 18:18:20 +0000 (-0400) Subject: staging: dgrp: check return value of alloc_tty_driver X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=178e485a0ebbfdb7165b4363d8fea2a07d650c0b;p=openwrt%2Fstaging%2Fblogic.git staging: dgrp: check return value of alloc_tty_driver alloc_tty_driver was always assumed to succeed. Add code to check the return value and return -ENOMEM if alloc_tty_driver fails. Reported-by: Fengguang Wu Signed-off-by: Bill Pemberton Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/dgrp/dgrp_tty.c b/drivers/staging/dgrp/dgrp_tty.c index 72f6fcfa9878..e125b03598d7 100644 --- a/drivers/staging/dgrp/dgrp_tty.c +++ b/drivers/staging/dgrp/dgrp_tty.c @@ -3173,6 +3173,9 @@ dgrp_tty_init(struct nd_struct *nd) */ nd->nd_serial_ttdriver = alloc_tty_driver(CHAN_MAX); + if (!nd->nd_serial_ttdriver) + return -ENOMEM; + sprintf(nd->nd_serial_name, "tty_dgrp_%s_", id); nd->nd_serial_ttdriver->owner = THIS_MODULE; @@ -3232,6 +3235,9 @@ dgrp_tty_init(struct nd_struct *nd) } nd->nd_callout_ttdriver = alloc_tty_driver(CHAN_MAX); + if (!nd->nd_callout_ttdriver) + return -ENOMEM; + sprintf(nd->nd_callout_name, "cu_dgrp_%s_", id); nd->nd_callout_ttdriver->owner = THIS_MODULE; @@ -3269,6 +3275,9 @@ dgrp_tty_init(struct nd_struct *nd) nd->nd_xprint_ttdriver = alloc_tty_driver(CHAN_MAX); + if (!nd->nd_xprint_ttdriver) + return -ENOMEM; + sprintf(nd->nd_xprint_name, "pr_dgrp_%s_", id); nd->nd_xprint_ttdriver->owner = THIS_MODULE;