[media] cec: return -EPERM when no LAs are configured
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 27 Feb 2017 12:18:35 +0000 (09:18 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 22 Mar 2017 14:11:46 +0000 (11:11 -0300)
The CEC_TRANSMIT ioctl now returns -EPERM if an attempt is made to
transmit a message for an unconfigured adapter (i.e. userspace
never called CEC_ADAP_S_LOG_ADDRS).

This differentiates this case from when LAs are configured, but no
physical address is set. In that case -ENONET is returned.

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

index 627cdf7b12d161c2cb8d7debbee61669b6b1b455..cea350ea2a526e180db18f5115e978ba3c0536da 100644 (file)
@@ -198,7 +198,9 @@ static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh,
                return -EINVAL;
 
        mutex_lock(&adap->lock);
-       if (adap->is_configuring)
+       if (adap->log_addrs.num_log_addrs == 0)
+               err = -EPERM;
+       else if (adap->is_configuring)
                err = -ENONET;
        else if (!adap->is_configured && (msg.msg[0] != 0xf0 || msg.reply))
                err = -ENONET;