media: staging: media: davinci_vpfe: – Fix for memory leak if decoder initialization fails. [Linux 4.9.187]

This Linux kernel change "media: staging: media: davinci_vpfe: – Fix for memory leak if decoder initialization fails" is included in the Linux 4.9.187 release. This change is authored by Shailendra Verma <shailendra.v [at] samsung.com> on Thu Nov 24 23:57:34 2016 -0500. The commit for this change in Linux stable tree is 209085e (patch) which is from upstream commit 6995a65. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 6995a65.

media: staging: media: davinci_vpfe: - Fix for memory leak if decoder initialization fails.

[ Upstream commit 6995a659101bd4effa41cebb067f9dc18d77520d ]

Fix to avoid possible memory leak if the decoder initialization
got failed.Free the allocated memory for file handle object
before return in case decoder initialization fails.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/staging/media/davinci_vpfe/vpfe_video.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 89dd6b9..e044080 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -423,6 +423,9 @@ static int vpfe_open(struct file *file)
    /* If decoder is not initialized. initialize it */
    if (!video->initialized && vpfe_update_pipe_state(video)) {
        mutex_unlock(&video->lock);
+       v4l2_fh_del(&handle->vfh);
+       v4l2_fh_exit(&handle->vfh);
+       kfree(handle);
        return -ENODEV;
    }
    /* Increment device users counter */

Leave a Reply

Your email address will not be published. Required fields are marked *