Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6633327d authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Mauro Carvalho Chehab
Browse files

[media] dvb_demux: fix deadlock in dmx_section_feed_release_filter()



dmx_section_feed_release_filter() locks dvbdmx->mutex and
if the feed is still filtering, it calls feed->stop_filtering(feed).
stop_filtering() is implemented by dmx_section_feed_stop_filtering()
that first of all try to lock the same mutex: dvbdmx->mutex.
That leads to a deadlock.
It does not happen often in practice because all callers of
release_filter() stop filtering by themselves.
So the problem can happen in case of race condition only.
The patch releases dvbdmx->mutex before call to feed->stop_filtering(feed)
and reacquires the mutex after that.
Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 858559a2
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1032,8 +1032,13 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
		return -EINVAL;
	}

	if (feed->is_filtering)
	if (feed->is_filtering) {
		/* release dvbdmx->mutex as far as 
		   it is acquired by stop_filtering() itself */
		mutex_unlock(&dvbdmx->mutex);
		feed->stop_filtering(feed);
		mutex_lock(&dvbdmx->mutex);
	}

	spin_lock_irq(&dvbdmx->lock);
	f = dvbdmxfeed->filter;