]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/dp_mst: Check crc4 value while building sideband message
authorBenjamin Gaignard <benjamin.gaignard@st.com>
Mon, 3 Feb 2020 12:16:20 +0000 (13:16 +0100)
committerBenjamin Gaignard <benjamin.gaignard@st.com>
Fri, 28 Feb 2020 12:08:00 +0000 (13:08 +0100)
Check that computed crc value is matching the one encoded in the message.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200203121620.9002-1-benjamin.gaignard@st.com
drivers/gpu/drm/drm_dp_mst_topology.c

index ba15a15bce9e803002e22ab52b55d88f17bd40d7..61e7beada83234f3010b2db0dbae4a6c146d5617 100644 (file)
@@ -736,6 +736,10 @@ static bool drm_dp_sideband_msg_build(struct drm_dp_sideband_msg_rx *msg,
        if (msg->curchunk_idx >= msg->curchunk_len) {
                /* do CRC */
                crc4 = drm_dp_msg_data_crc4(msg->chunk, msg->curchunk_len - 1);
+               if (crc4 != msg->chunk[msg->curchunk_len - 1])
+                       print_hex_dump(KERN_DEBUG, "wrong crc",
+                                      DUMP_PREFIX_NONE, 16, 1,
+                                      msg->chunk,  msg->curchunk_len, false);
                /* copy chunk into bigger msg */
                memcpy(&msg->msg[msg->curlen], msg->chunk, msg->curchunk_len - 1);
                msg->curlen += msg->curchunk_len - 1;