提交 29cd13cf 编写于 作者: N Navid Emamdoost 提交者: Daniel Vetter

drm/v3d: Fix memory leak in v3d_submit_cl_ioctl

In the impelementation of v3d_submit_cl_ioctl() there are two memory
leaks. One is when allocation for bin fails, and the other is when bin
initialization fails. If kcalloc fails to allocate memory for bin then
render->base should be put. Also, if v3d_job_init() fails to initialize
bin->base then allocated memory for bin should be released.

Fixes: a783a09e ("drm/v3d: Refactor job management.")
Signed-off-by: NNavid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: NEric Anholt <eric@anholt.net>
Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20191021185250.26130-1-navid.emamdoost@gmail.com
上级 4cad2a57
无相关合并请求
...@@ -557,13 +557,16 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, ...@@ -557,13 +557,16 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
if (args->bcl_start != args->bcl_end) { if (args->bcl_start != args->bcl_end) {
bin = kcalloc(1, sizeof(*bin), GFP_KERNEL); bin = kcalloc(1, sizeof(*bin), GFP_KERNEL);
if (!bin) if (!bin) {
v3d_job_put(&render->base);
return -ENOMEM; return -ENOMEM;
}
ret = v3d_job_init(v3d, file_priv, &bin->base, ret = v3d_job_init(v3d, file_priv, &bin->base,
v3d_job_free, args->in_sync_bcl); v3d_job_free, args->in_sync_bcl);
if (ret) { if (ret) {
v3d_job_put(&render->base); v3d_job_put(&render->base);
kfree(bin);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部