Commit 28e347de authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[IRDA]: Fix BUG() in irlmp seq file code.

parent 1105dc16
...@@ -1787,22 +1787,21 @@ struct irlmp_iter_state { ...@@ -1787,22 +1787,21 @@ struct irlmp_iter_state {
#define LSAP_START_TOKEN ((void *)1) #define LSAP_START_TOKEN ((void *)1)
#define LINK_START_TOKEN ((void *)2) #define LINK_START_TOKEN ((void *)2)
static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, loff_t *off)
hashbin_t *bin, loff_t *off)
{ {
void *element; void *element;
spin_lock_irqsave(&bin->hb_spinlock, iter->flags); spin_lock_irqsave(&iter->hashbin->hb_spinlock, iter->flags);
for (element = hashbin_get_first(bin); for (element = hashbin_get_first(iter->hashbin);
element != NULL; element != NULL;
element = hashbin_get_next(bin)) { element = hashbin_get_next(iter->hashbin)) {
if (!off || *off-- == 0) { if (!off || *off-- == 0) {
/* NB: hashbin left locked */ /* NB: hashbin left locked */
iter->hashbin = bin;
return element; return element;
} }
} }
spin_unlock_irqrestore(&bin->hb_spinlock, iter->flags); spin_unlock_irqrestore(&iter->hashbin->hb_spinlock, iter->flags);
iter->hashbin = NULL;
return NULL; return NULL;
} }
...@@ -1813,18 +1812,19 @@ static void *irlmp_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -1813,18 +1812,19 @@ static void *irlmp_seq_start(struct seq_file *seq, loff_t *pos)
void *v; void *v;
loff_t off = *pos; loff_t off = *pos;
iter->hashbin = NULL;
if (off-- == 0) if (off-- == 0)
return LSAP_START_TOKEN; return LSAP_START_TOKEN;
v = irlmp_seq_hb_idx(iter, irlmp->unconnected_lsaps, &off); iter->hashbin = irlmp->unconnected_lsaps;
v = irlmp_seq_hb_idx(iter, &off);
if (v) if (v)
return v; return v;
if (off-- == 0) if (off-- == 0)
return LINK_START_TOKEN; return LINK_START_TOKEN;
return irlmp_seq_hb_idx(iter, irlmp->links, &off); iter->hashbin = irlmp->links;
return irlmp_seq_hb_idx(iter, &off);
} }
static void *irlmp_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void *irlmp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
...@@ -1833,27 +1833,29 @@ static void *irlmp_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -1833,27 +1833,29 @@ static void *irlmp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
++*pos; ++*pos;
if (v == LSAP_START_TOKEN) { if (v == LSAP_START_TOKEN) { /* start of list of lsaps */
v = irlmp_seq_hb_idx(iter, irlmp->unconnected_lsaps, NULL); iter->hashbin = irlmp->unconnected_lsaps;
v = irlmp_seq_hb_idx(iter, NULL);
return v ? v : LINK_START_TOKEN; return v ? v : LINK_START_TOKEN;
} }
if (v == LINK_START_TOKEN) if (v == LINK_START_TOKEN) { /* start of list of links */
return irlmp_seq_hb_idx(iter, irlmp->links, NULL); iter->hashbin = irlmp->links;
return irlmp_seq_hb_idx(iter, NULL);
ASSERT( iter->hashbin != NULL, return NULL; ); }
v = hashbin_get_next(iter->hashbin); v = hashbin_get_next(iter->hashbin);
if (v)
return v;
spin_unlock_irqrestore(&iter->hashbin->hb_spinlock, iter->flags); if (v == NULL) { /* no more in this hash bin */
spin_unlock_irqrestore(&iter->hashbin->hb_spinlock,
iter->flags);
if (iter->hashbin == irlmp->unconnected_lsaps)
v = LINK_START_TOKEN;
if (iter->hashbin == irlmp->unconnected_lsaps) {
iter->hashbin = NULL; iter->hashbin = NULL;
return LINK_START_TOKEN;
} }
return NULL; return v;
} }
static void irlmp_seq_stop(struct seq_file *seq, void *v) static void irlmp_seq_stop(struct seq_file *seq, void *v)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment