summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi-base.c
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-01-10 21:42:49 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-01-10 21:42:49 +0000
commit2fe67a197159d7425964c66f151cd4e6e7f0b53d (patch)
treeca1db44740e8e69eb3b0842ab6b813fe4139a54f /drivers/dahdi/dahdi-base.c
parent823557a20bc704e1ce472adb15e84be8fcb53a85 (diff)
cleaner error handling in dahdi_register
* Better error handling in dahdi_register. * Fail registration if fails creating proc entry for span. Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> Acked-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9626 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi-base.c')
-rw-r--r--drivers/dahdi/dahdi-base.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index acecd94..30b04e6 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -6481,6 +6481,8 @@ static int span_sysfs_create(struct dahdi_span *span)
NULL, chan_name);
if (IS_ERR(dummy)) {
res = PTR_ERR(dummy);
+ chan_err(chan, "Failed creating sysfs device: %d\n",
+ res);
goto cleanup;
}
@@ -6606,10 +6608,17 @@ static int _dahdi_register(struct dahdi_span *span, int prefmaster)
span->proc_entry = create_proc_read_entry(tempfile, 0444,
root_proc_entry, dahdi_proc_read,
(int *) (long) span->spanno);
+ if (!span->proc_entry) {
+ res = -EFAULT;
+ span_err(span, "Error creating procfs entry\n");
+ goto cleanup;
+ }
}
#endif
res = span_sysfs_create(span);
+ if (res)
+ goto cleanup;
if (debug & DEBUG_MAIN) {
module_printk(KERN_NOTICE, "Registered Span %d ('%s') with "
@@ -6626,6 +6635,23 @@ static int _dahdi_register(struct dahdi_span *span, int prefmaster)
__dahdi_find_master_span();
return 0;
+
+cleanup:
+#ifdef CONFIG_PROC_FS
+ if (span->proc_entry) {
+ char tempfile[17];
+
+ snprintf(tempfile, sizeof(tempfile), "dahdi/%d", span->spanno);
+ remove_proc_entry(tempfile, NULL);
+ span->proc_entry = NULL;
+ }
+#endif
+ for (x = 0; x < span->channels; x++) {
+ struct dahdi_chan *chan = span->chans[x];
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &chan->flags))
+ dahdi_chan_unreg(chan);
+ }
+ return res;
}
/**