* [PATCH 0/2] cec: improve robustness of the framework
@ 2020-09-08 10:26 Hans Verkuil
2020-09-08 10:26 ` [PATCH 1/2] cec-core.c: stop kthread_config before kthread Hans Verkuil
2020-09-08 10:26 ` [PATCH 2/2] cec-adap.c: add 'unregistered' checks Hans Verkuil
0 siblings, 2 replies; 3+ messages in thread
From: Hans Verkuil @ 2020-09-08 10:26 UTC (permalink / raw)
To: linux-media
Add two patches that make the framework a bit more robust.
Regards,
Hans
Hans Verkuil (2):
cec-core.c: stop kthread_config before kthread
cec-adap.c: add 'unregistered' checks
drivers/media/cec/core/cec-adap.c | 6 ++++++
drivers/media/cec/core/cec-core.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
--
2.27.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] cec-core.c: stop kthread_config before kthread
2020-09-08 10:26 [PATCH 0/2] cec: improve robustness of the framework Hans Verkuil
@ 2020-09-08 10:26 ` Hans Verkuil
2020-09-08 10:26 ` [PATCH 2/2] cec-adap.c: add 'unregistered' checks Hans Verkuil
1 sibling, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2020-09-08 10:26 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
The kthread_config relies on the main kthread (message processing
loop) to be present, so stop kthread_config before kthread.
It's unlikely to be a problem (and I've never seen any issues), but
if nothing else it makes sense to stop the threads in this order.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
drivers/media/cec/core/cec-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
index 3ee16f672d68..ece236291f35 100644
--- a/drivers/media/cec/core/cec-core.c
+++ b/drivers/media/cec/core/cec-core.c
@@ -396,9 +396,9 @@ void cec_delete_adapter(struct cec_adapter *adap)
{
if (IS_ERR_OR_NULL(adap))
return;
- kthread_stop(adap->kthread);
if (adap->kthread_config)
kthread_stop(adap->kthread_config);
+ kthread_stop(adap->kthread);
if (adap->ops->adap_free)
adap->ops->adap_free(adap);
#ifdef CONFIG_MEDIA_CEC_RC
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] cec-adap.c: add 'unregistered' checks
2020-09-08 10:26 [PATCH 0/2] cec: improve robustness of the framework Hans Verkuil
2020-09-08 10:26 ` [PATCH 1/2] cec-core.c: stop kthread_config before kthread Hans Verkuil
@ 2020-09-08 10:26 ` Hans Verkuil
1 sibling, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2020-09-08 10:26 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil
Make the code a bit more robust by checking if the adapter has
been unregistered at the start of cec_transmit_msg_fh() and
cec_received_msg_ts(). If it is unregistered, then just return.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
drivers/media/cec/core/cec-adap.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index 3153c401cb65..d5d5d28d0b36 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -751,6 +751,9 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
struct cec_data *data;
bool is_raw = msg_is_raw(msg);
+ if (adap->devnode.unregistered)
+ return -ENODEV;
+
msg->rx_ts = 0;
msg->tx_ts = 0;
msg->rx_status = 0;
@@ -1049,6 +1052,9 @@ void cec_received_msg_ts(struct cec_adapter *adap,
if (WARN_ON(!msg->len || msg->len > CEC_MAX_MSG_SIZE))
return;
+ if (adap->devnode.unregistered)
+ return;
+
/*
* Some CEC adapters will receive the messages that they transmitted.
* This test filters out those messages by checking if we are the
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-08 10:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 10:26 [PATCH 0/2] cec: improve robustness of the framework Hans Verkuil
2020-09-08 10:26 ` [PATCH 1/2] cec-core.c: stop kthread_config before kthread Hans Verkuil
2020-09-08 10:26 ` [PATCH 2/2] cec-adap.c: add 'unregistered' checks Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).