drm/dp_mst: fix multiple frees of tx->bytes
authorColin Ian King <colin.king@canonical.com>
Wed, 20 Nov 2019 17:35:09 +0000 (17:35 +0000)
committerLyude Paul <lyude@redhat.com>
Wed, 20 Nov 2019 19:16:15 +0000 (14:16 -0500)
Currently tx->bytes is being freed r->num_transactions number of
times because tx is not being set correctly. Fix this by setting
tx to &r->transactions[i] so that the correct objects are being
freed on each loop iteration.

Addresses-Coverity: ("Double free")
Fixes: 2f015ec6eab6 ("drm/dp_mst: Add sideband down request tracing + selftests")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191120173509.347490-1-colin.king@canonical.com
drivers/gpu/drm/drm_dp_mst_topology.c

index b854a422a523d7934efeb53b29b548772b4cf0a8..1437bc46368b41fc228451e8f8507cfcadc3bbe6 100644 (file)
@@ -504,8 +504,10 @@ drm_dp_decode_sideband_req(const struct drm_dp_sideband_msg_tx *raw,
                        }
 
                        if (failed) {
-                               for (i = 0; i < r->num_transactions; i++)
+                               for (i = 0; i < r->num_transactions; i++) {
+                                       tx = &r->transactions[i];
                                        kfree(tx->bytes);
+                               }
                                return -ENOMEM;
                        }