[PATCH] Staging: media: platform: davinci: - Fix for memory leak

From: Shailendra Verma
Date: Thu Nov 24 2016 - 23:54:51 EST


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@xxxxxxxxxxx>
---
drivers/media/platform/davinci/vpfe_capture.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index 6efb2f1..188b333 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -526,6 +526,8 @@ static int vpfe_open(struct file *file)
if (!vpfe_dev->initialized) {
if (vpfe_initialize_device(vpfe_dev)) {
mutex_unlock(&vpfe_dev->lock);
+ v4l2_fh_exit(&fh->fh);
+ kfree(fh);
return -ENODEV;
}
}
--
1.7.9.5