* [PATCH][next] drm/selftests/test-drm_dp_mst_helper: fix memory leak allocated to 'out'
@ 2020-11-18 13:49 Colin King
2020-11-18 13:55 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-11-18 13:49 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Lyude Paul, Lee Jones, dri-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently when txmsg fails to allocate then there is a leak on 'out'. Fix
this by setting result to false and exiting via the clean up exit path.
Note since txmsg is NULL at this point, the kfree of txmsg is a no-op.
Addresses-Coverity: ("Resource leak")
Fixes: 09234b88ef55 ("drm/selftests/test-drm_dp_mst_helper: Move 'sideband_msg_req_encode_decode' onto the heap")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
index 6b4759ed6bfd..dbac073ed385 100644
--- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
+++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
@@ -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);
--
2.28.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH][next] drm/selftests/test-drm_dp_mst_helper: fix memory leak allocated to 'out'
2020-11-18 13:49 [PATCH][next] drm/selftests/test-drm_dp_mst_helper: fix memory leak allocated to 'out' Colin King
@ 2020-11-18 13:55 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2020-11-18 13:55 UTC (permalink / raw)
To: Colin King
Cc: David Airlie, Daniel Vetter, Lyude Paul, dri-devel,
kernel-janitors, linux-kernel
On Wed, 18 Nov 2020, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently when txmsg fails to allocate then there is a leak on 'out'. Fix
> this by setting result to false and exiting via the clean up exit path.
> Note since txmsg is NULL at this point, the kfree of txmsg is a no-op.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 09234b88ef55 ("drm/selftests/test-drm_dp_mst_helper: Move 'sideband_msg_req_encode_decode' onto the heap")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
This is fixed in my local branch.
Looks like the wrong version of the patch was sent/applied.
Either way, thanks for the fix Colin.
Reviewed-by: Lee Jones <lee.jones@linaro.org>
> diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> index 6b4759ed6bfd..dbac073ed385 100644
> --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> @@ -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);
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-18 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18 13:49 [PATCH][next] drm/selftests/test-drm_dp_mst_helper: fix memory leak allocated to 'out' Colin King
2020-11-18 13:55 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®