media: cec-adap.c: add 'unregistered' checks
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 8 Sep 2020 10:26:11 +0000 (12:26 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sat, 26 Sep 2020 08:25:13 +0000 (10:25 +0200)
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>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/cec/core/cec-adap.c

index 80fd5165f658b52fc03124671d235495fb41d632..3f016caa45ba7127568b3ba5e49f4bca516d2cce 100644 (file)
@@ -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