Skip to contentSkip to conversation

drm/selftest: fix potential memleak in error branch

PATCH In review Bernard Zhao 2 participants 2 messages Nov 17, 2021 – Nov 22, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/selftest: fix potential memleak in error branch

This patch try to fix the potential memleak in error branch.

---
 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c +4 -2
index 6b4759ed6bfd..dbac073ed385 100644
@@ -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)
-		return false;
+	if (!txmsg) {
+		result = false;
+		goto out;
+	}
 
 	drm_dp_encode_sideband_req(in, txmsg);
 	ret = drm_dp_decode_sideband_req(txmsg, out);
Signature · 1 line
2.33.1
Reviewed-by on v1 1/1
#1 lore raw

I wonder what vivo's interested in this for!

Anyway:

Do you need me to push this to drm-misc-next for you?

Quoted 26 lines · Bernard Zhao

This patch try to fix the potential memleak in error branch.

---
 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c +0 -0
index 6b4759ed6bfd..dbac073ed385 100644
@@ -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)
-               return false;
+       if (!txmsg) {
+               result = false;
+               goto out;
+       }

        drm_dp_encode_sideband_req(in, txmsg); ret = drm_dp_decode_sideband_req(txmsg, out);

Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat