summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2010-09-20 20:33:31 +0000
committerShaun Ruffell <sruffell@digium.com>2010-09-20 20:33:31 +0000
commitcf67c320b17f96e861ab8b6321fb64f764b87854 (patch)
treecce36c5c7b1ce9cc51e14dc66bfcde656d5e747e
parentec7c856b7b91e6ef6b8c7acc72df68a8dfc9005d (diff)
dahdi: Reduce chans array indexing in dahdi_chan_unreg.
Review: https://reviewboard.asterisk.org/r/905/ Signed-off-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9368 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/dahdi-base.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index 9b0ccdc..c44a9da 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -2042,29 +2042,32 @@ static void dahdi_chan_unreg(struct dahdi_chan *chan)
}
#endif
maxchans = 0;
- for (x=1;x<DAHDI_MAX_CHANNELS;x++)
- if (chans[x]) {
- maxchans = x + 1;
- /* Remove anyone pointing to us as master
- and make them their own thing */
- if (chans[x]->master == chan) {
- chans[x]->master = chans[x];
- }
- if ((chans[x]->confna == chan->channo) &&
- is_monitor_mode(chans[x]->confmode) &&
- ((chans[x]->confmode & DAHDI_CONF_MODE_MASK) == DAHDI_CONF_DIGITALMON)) {
- /* Take them out of conference with us */
- /* release conference resource if any */
- if (chans[x]->confna) {
- dahdi_check_conf(chans[x]->confna);
- if (chans[x]->span)
- dahdi_disable_dacs(chans[x]);
- }
- chans[x]->confna = 0;
- chans[x]->_confn = 0;
- chans[x]->confmode = 0;
+ for (x = 1; x < DAHDI_MAX_CHANNELS; x++) {
+ struct dahdi_chan *const pos = chans[x];
+ if (!pos)
+ continue;
+ maxchans = x + 1;
+ /* Remove anyone pointing to us as master
+ and make them their own thing */
+ if (pos->master == chan)
+ pos->master = pos;
+
+ if ((pos->confna == chan->channo) &&
+ is_monitor_mode(pos->confmode) &&
+ ((pos->confmode & DAHDI_CONF_MODE_MASK) ==
+ DAHDI_CONF_DIGITALMON)) {
+ /* Take them out of conference with us */
+ /* release conference resource if any */
+ if (pos->confna) {
+ dahdi_check_conf(pos->confna);
+ if (pos->span)
+ dahdi_disable_dacs(pos);
}
+ pos->confna = 0;
+ pos->_confn = 0;
+ pos->confmode = 0;
}
+ }
chan->channo = -1;
write_unlock_irqrestore(&chan_lock, flags);
}