A channel-less span should not crash dahdi

* Always check span->channels before accessing span->chans[0]
* Clean one dev_notice() text that accessed span->chans[0]
* Check channels in basechan_show() sysfs attribute

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10450 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Oron Peled
2012-01-25 21:18:25 +00:00
committed by Tzafrir Cohen
parent b8b7b86332
commit ed6def895b
2 changed files with 4 additions and 3 deletions

View File

@@ -6882,9 +6882,8 @@ static int _dahdi_assign_span(struct dahdi_span *span, unsigned int spanno,
if (test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) {
dev_notice(span_device(span),
"local span %d is already assigned span %d "
"with base channel %d\n", local_spanno(span), span->spanno,
span->chans[0]->channo);
"local span %d is already assigned span %d\n",
local_spanno(span), span->spanno);
return -EINVAL;
}

View File

@@ -250,6 +250,8 @@ static BUS_ATTR_READER(basechan_show, dev, buf)
struct dahdi_span *span;
span = dev_to_span(dev);
if (!span->channels)
return -ENODEV;
return sprintf(buf, "%d\n", span->chans[0]->channo);
}