From 7b91d5acf602da6f98aad9fa49b223dfc94640df Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 11 Jan 2010 14:50:04 +0000 Subject: Fail gracefully if we already have more than 1024 channels. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@7850 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/dahdi-base.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'drivers/dahdi/dahdi-base.c') diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 8b7689e..39aa64b 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -5723,6 +5723,7 @@ static long dahdi_ioctl_compat(struct file *file, unsigned int cmd, int dahdi_register(struct dahdi_span *span, int prefmaster) { int x; + int res = 0; if (!span) return -EINVAL; @@ -5768,7 +5769,12 @@ int dahdi_register(struct dahdi_span *span, int prefmaster) for (x = 0; x < span->channels; x++) { span->chans[x]->span = span; - dahdi_chan_reg(span->chans[x]); + res = dahdi_chan_reg(span->chans[x]); + if (res) { + for (x--; x >= 0; x--) + dahdi_chan_unreg(span->chans[x]); + goto unreg_channels; + } } #ifdef CONFIG_PROC_FS @@ -5804,6 +5810,10 @@ int dahdi_register(struct dahdi_span *span, int prefmaster) } return 0; + +unreg_channels: + spans[span->spanno] = NULL; + return res; } -- cgit v1.2.3