This patch fixes memory leaks on error escapes in wave5_vpu_open_enc() and wave5_vpu_open_dec(). Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer") Signed-off-by: Zeng Chi <zengchi@xxxxxxxxxx> --- drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 4 +++- drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c index 8b1417ece96e..2d3e8a184f93 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c @@ -1792,8 +1792,10 @@ static int wave5_vpu_open_dec(struct file *filp) int ret = 0; inst = kzalloc(sizeof(*inst), GFP_KERNEL); - if (!inst) + if (!inst) { + kfree(inst); return -ENOMEM; + } inst->dev = dev; inst->type = VPU_INST_TYPE_DEC; diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c index f29cfa3af94a..cbf6cb6e07aa 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -1537,8 +1537,10 @@ static int wave5_vpu_open_enc(struct file *filp) int ret = 0; inst = kzalloc(sizeof(*inst), GFP_KERNEL); - if (!inst) + if (!inst) { + kfree(inst); return -ENOMEM; + } v4l2_ctrl_hdl = &inst->v4l2_ctrl_hdl; inst->dev = dev; -- 2.25.1