Skip to content

Commit 63d171f

Browse files
Hans Verkuilmchehab
authored andcommitted
media: cec: cec_transmit_msg_fh: do sanity checks first
The code that fills in the CEC_MSG_CDC_MESSAGE physical address is now done after the sanity checks. It also only does this if the message length is >= 4 (i.e. there is room for the physical address). Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent 00ccd26 commit 63d171f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎drivers/media/cec/cec-adap.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
740740
else
741741
msg->flags = 0;
742742

743-
if (msg->len > 1 && msg->msg[1] == CEC_MSG_CDC_MESSAGE) {
744-
msg->msg[2] = adap->phys_addr >> 8;
745-
msg->msg[3] = adap->phys_addr & 0xff;
746-
}
747-
748743
/* Sanity checks */
749744
if (msg->len == 0 || msg->len > CEC_MAX_MSG_SIZE) {
750745
dprintk(1, "%s: invalid length %d\n", __func__, msg->len);
@@ -765,6 +760,12 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
765760
dprintk(1, "%s: can't reply to poll msg\n", __func__);
766761
return -EINVAL;
767762
}
763+
764+
if (msg->len >= 4 && msg->msg[1] == CEC_MSG_CDC_MESSAGE) {
765+
msg->msg[2] = adap->phys_addr >> 8;
766+
msg->msg[3] = adap->phys_addr & 0xff;
767+
}
768+
768769
if (msg->len == 1) {
769770
if (cec_msg_destination(msg) == 0xf) {
770771
dprintk(1, "%s: invalid poll message\n", __func__);

0 commit comments

Comments
 (0)