drm/selftests/test-drm_dp_mst_helper: Fix memory leak in sideband_msg_req_encode_decode
authorJosé Expósito <jose.exposito89@gmail.com>
Sat, 8 Jan 2022 16:58:12 +0000 (17:58 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 19 Jan 2022 15:14:45 +0000 (16:14 +0100)
Avoid leaking the "out" variable if it is not possible to allocate
the "txmsg" variable.

Fixes: 09234b88ef55 ("drm/selftests/test-drm_dp_mst_helper: Move 'sideband_msg_req_encode_decode' onto the heap")
Addresses-Coverity-ID: 1475685 ("Resource leak")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220108165812.46797-1-jose.exposito89@gmail.com
drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c

index 4004e6d..fc1deb1 100644 (file)
@@ -131,8 +131,10 @@ sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
                return false;
 
        txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
-       if (!txmsg)
+       if (!txmsg) {
+               kfree(out);
                return false;
+       }
 
        drm_dp_encode_sideband_req(in, txmsg);
        ret = drm_dp_decode_sideband_req(txmsg, out);