summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-01-11 14:50:04 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-01-11 14:50:04 +0000
commit7b91d5acf602da6f98aad9fa49b223dfc94640df (patch)
tree1c065f7deafc871cfacf793f674e877ec7e90dc1
parent7789d3a645138ab87a8047ee93bd7fafa86ee25b (diff)
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
-rw-r--r--drivers/dahdi/dahdi-base.c12
1 files changed, 11 insertions, 1 deletions
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;
}