Commit d07c7afd authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] DVB: Fix feed list handling bugs in demux

 - corrected handling of feed lists (Andres Oberritter)
parent 950422ae
...@@ -542,33 +542,38 @@ static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux) ...@@ -542,33 +542,38 @@ static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux)
return &demux->feed[i]; return &demux->feed[i];
} }
static int dvb_demux_feed_find(struct dvb_demux_feed *feed)
static int dmx_pid_set (u16 pid, struct dvb_demux_feed *feed)
{ {
struct dvb_demux *demux = feed->demux; struct dvb_demux_feed *entry;
struct list_head *pos, *n, *head=&demux->feed_list;
if (pid > DMX_MAX_PID) list_for_each_entry(entry, &feed->demux->feed_list, list_head)
return -EINVAL; if (entry == feed)
return 1;
if (pid == feed->pid)
return 0; return 0;
if (feed->pid <= DMX_MAX_PID) {
list_for_each_safe(pos, n, head) {
if (DMX_FEED_ENTRY(pos)->pid == feed->pid) {
list_del(pos);
break;
}
} }
static void dvb_demux_feed_add(struct dvb_demux_feed *feed)
{
if (dvb_demux_feed_find(feed)) {
printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n",
__FUNCTION__, feed->type, feed->state, feed->pid);
return;
} }
list_add(&feed->list_head, head); list_add(&feed->list_head, &feed->demux->feed_list);
feed->pid = pid; }
return 0; static void dvb_demux_feed_del(struct dvb_demux_feed *feed)
{
if (!(dvb_demux_feed_find(feed))) {
printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n",
__FUNCTION__, feed->type, feed->state, feed->pid);
return;
} }
list_del(&feed->list_head);
}
static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
enum dmx_ts_pes pes_type, size_t callback_length, enum dmx_ts_pes pes_type, size_t callback_length,
...@@ -577,7 +582,9 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, ...@@ -577,7 +582,9 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
{ {
struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
int ret;
if (pid > DMX_MAX_PID)
return -EINVAL;
if (down_interruptible (&demux->mutex)) if (down_interruptible (&demux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -594,26 +601,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, ...@@ -594,26 +601,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
return -EINVAL; return -EINVAL;
} }
if ((pes_type != DMX_TS_PES_PCR0) &&
(pes_type != DMX_TS_PES_PCR1) &&
(pes_type != DMX_TS_PES_PCR2) &&
(pes_type != DMX_TS_PES_PCR3)) {
if ((ret = dmx_pid_set(pid, feed))<0) {
up(&demux->mutex);
return ret;
}
} else
feed->pid = pid;
demux->pesfilter[pes_type] = feed; demux->pesfilter[pes_type] = feed;
demux->pids[pes_type] = feed->pid; demux->pids[pes_type] = pid;
} else {
if ((ret = dmx_pid_set(pid, feed))<0) {
up(&demux->mutex);
return ret;
}
} }
dvb_demux_feed_add(feed);
feed->pid = pid;
feed->buffer_size = circular_buffer_size; feed->buffer_size = circular_buffer_size;
feed->descramble = descramble; feed->descramble = descramble;
feed->timeout = timeout; feed->timeout = timeout;
...@@ -757,7 +751,6 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ ...@@ -757,7 +751,6 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_
{ {
struct dvb_demux *demux = (struct dvb_demux *) dmx; struct dvb_demux *demux = (struct dvb_demux *) dmx;
struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
struct list_head *pos, *n, *head=&demux->feed_list;
if (down_interruptible (&demux->mutex)) if (down_interruptible (&demux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -777,14 +770,9 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ ...@@ -777,14 +770,9 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_
feed->state = DMX_STATE_FREE; feed->state = DMX_STATE_FREE;
feed->filter->state = DMX_STATE_FREE; feed->filter->state = DMX_STATE_FREE;
if (feed->pid <= DMX_MAX_PID) { dvb_demux_feed_del(feed);
list_for_each_safe(pos, n, head)
if (DMX_FEED_ENTRY(pos)->pid == feed->pid) {
list_del(pos);
break;
}
feed->pid = 0xffff; feed->pid = 0xffff;
}
if (feed->ts_type & TS_DECODER) if (feed->ts_type & TS_DECODER)
demux->pesfilter[feed->pes_type] = NULL; demux->pesfilter[feed->pes_type] = NULL;
...@@ -836,7 +824,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, ...@@ -836,7 +824,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed,
{ {
struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
struct dvb_demux *dvbdmx=dvbdmxfeed->demux; struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
struct list_head *pos, *n, *head=&dvbdmx->feed_list;
if (pid>0x1fff) if (pid>0x1fff)
return -EINVAL; return -EINVAL;
...@@ -844,16 +831,7 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, ...@@ -844,16 +831,7 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed,
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (dvbdmxfeed->pid <= DMX_MAX_PID) { dvb_demux_feed_add(dvbdmxfeed);
list_for_each_safe(pos, n, head) {
if (DMX_FEED_ENTRY(pos)->pid == dvbdmxfeed->pid) {
list_del(pos);
break;
}
}
}
list_add(&dvbdmxfeed->list_head, head);
dvbdmxfeed->pid = pid; dvbdmxfeed->pid = pid;
dvbdmxfeed->buffer_size=circular_buffer_size; dvbdmxfeed->buffer_size=circular_buffer_size;
...@@ -1045,7 +1023,6 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, ...@@ -1045,7 +1023,6 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
{ {
struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
struct dvb_demux *dvbdmx=(struct dvb_demux *) demux; struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
struct list_head *pos, *n, *head=&dvbdmx->feed_list;
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -1062,15 +1039,9 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, ...@@ -1062,15 +1039,9 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
#endif #endif
dvbdmxfeed->state=DMX_STATE_FREE; dvbdmxfeed->state=DMX_STATE_FREE;
if (dvbdmxfeed->pid <= DMX_MAX_PID) { dvb_demux_feed_del(dvbdmxfeed);
list_for_each_safe(pos, n, head) {
if (DMX_FEED_ENTRY(pos)->pid == dvbdmxfeed->pid) {
list_del(pos);
break;
}
}
dvbdmxfeed->pid = 0xffff; dvbdmxfeed->pid = 0xffff;
}
up(&dvbdmx->mutex); up(&dvbdmx->mutex);
return 0; return 0;
......
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