drm/crc-debugfs: Fix memleak in crc_control_write
Subsystems (2)
PATCH 1/1 drm/crc-debugfs: Fix memleak in crc_control_write
When verify_crc_source() fails, source needs to be freed. However, current code is returning directly and ends up leaking memory.
--- drivers/gpu/drm/drm_debugfs_crc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_debugfs_crc.c +3 -1
@@ -144,8 +144,10 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf, source[len -1 ] ='\0' ; ret = crtc->funcs->verify_crc_source (crtc, source, &values_cnt); -if (ret) +if (ret) { +kfree (source);return ret; + }spin_lock_irq (&crc->lock);
Signature · 1 line
2.17.1
Hi Dinghao,
Thank you for the patch.
Quoted 5 lines · Dinghao Liu
When
verify_crc_source()fails, source needs to be freed. However, current code is returning directly and ends up leaking memory.Fixes c0811a7d5befe ("drm/crc: Cleanup crtc_crc_open function")
I think the issue was introduced in d5cc15a0c66e ("drm: crc: Introduce verify_crc_source callback"). Apart from that,
Quoted 21 lines
Signed-off-by Dinghao Liu <[email protected]>--- drivers/gpu/drm/drm_debugfs_crc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_debugfs_crc.c +3
-1@@ -144,8 +144,10 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf, source[len -1 ] ='\0' ; ret = crtc->funcs->verify_crc_source (crtc, source, &values_cnt); -if (ret) +if (ret) { +kfree (source);return ret; + }spin_lock_irq (&crc->lock);
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
AppliedQuoted 9 lines · Laurent Pinchart
Hi Dinghao,
Thank you for the patch.
Quoted 4 lines · Dinghao Liu
When
verify_crc_source()fails, source needs to be freed. However, current code is returning directly and ends up leaking memory.
Quoted 6 lines
Quoted 1 line
Fixes c0811a7d5befe ("drm/crc: Cleanup crtc_crc_open function")I think the issue was introduced in
d5cc15a0c66e("drm: crc: Introduceverify_crc_sourcecallback"). Apart from that,Reviewed-by Laurent Pinchart <[email protected]>
Pushed to drm-misc-next.
-Daniel
Quoted 27 lines
Quoted 22 lines
Signed-off-by Dinghao Liu <[email protected]>--- drivers/gpu/drm/drm_debugfs_crc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_debugfs_crc.c +3
-1@@ -144,8 +144,10 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf, source[len -1 ] ='\0' ; ret = crtc->funcs->verify_crc_source (crtc, source, &values_cnt); -if (ret) +if (ret) { +kfree (source);return ret; + }spin_lock_irq (&crc->lock);Signature · 3 lines
Regards, Laurent Pinchart
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel