From ac71da82b8b5decadf5e8781e9e3dbc82447093b Mon Sep 17 00:00:00 2001 From: Holger Waechtler Date: Sun, 29 Jun 2003 21:52:02 +0000 Subject: add some sanity checks and additional locking in synchronizer code --- linux/drivers/media/dvb/dvb-core/dvb_demux.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'linux') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_demux.c b/linux/drivers/media/dvb/dvb-core/dvb_demux.c index b5edf3af2..affe8b3a8 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_demux.c @@ -404,15 +404,18 @@ void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t cou void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) { int p = 0,i, j; - + + spin_lock(&demux->lock); + if ((i = demux->tsbufp)) { if (count < (j=188-i)) { memcpy(&demux->tsbuf[i], buf, count); demux->tsbufp += count; - return; + goto bailout; } memcpy(&demux->tsbuf[i], buf, j); - dvb_dmx_swfilter_packet(demux, demux->tsbuf); + if (demux->tsbuf[0] == 0x47) + dvb_dmx_swfilter_packet(demux, demux->tsbuf); demux->tsbufp = 0; p += j; } @@ -426,11 +429,14 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) i = count-p; memcpy(demux->tsbuf, buf+p, i); demux->tsbufp=i; - return; + goto bailout; } } else p++; } + +bailout: + spin_unlock(&demux->lock); } -- cgit v1.2.3