]> git.karo-electronics.de Git - karo-tx-linux.git/commit
[media] cec: fix race between configuring and unconfiguring
authorHans Verkuil <hansverk@cisco.com>
Fri, 9 Dec 2016 14:00:49 +0000 (12:00 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 21 Dec 2016 09:03:27 +0000 (07:03 -0200)
commitf60f35609f89ef4fee73776bc1ef697923251995
tree0fe5ffbf5548a46f74b70bd40d09eefefcc35600
parentd3d64bc7408f1ff0b0ff8354056e2a48eda5886d
[media] cec: fix race between configuring and unconfiguring

This race was discovered by running cec-compliance -A with the cec module debug
parameter set to 2: suddenly the test would fail.

It turns out that this happens when the test configures the adapter in
non-blocking mode, then it waits for the CEC_EVENT_STATE_CHANGE event and once
the event is received it unconfigures the adapter.

What happened was that the unconfigure was executed while the configure was
still transmitting the Report Features and Report Physical Address messages.
This messed up the internal state of the cec_adapter.

The fix is to transmit those messages with the adap->lock mutex held (this will
just queue them up in the internal transmit queue, and not actually transmit
anything yet). Only unlock the mutex once everything is done. The main thread
will dequeue the messages from the internal transmit queue and transmit them
one by one, unless an unconfigure was done, and in that case any messages are
just dropped.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/cec/cec-adap.c