sde: rotator: Add null pointer checks
Pointers in some cases are dereferenced even after
freeing memory region pointed by them. Assign NULL to
free pointers and perform proper NULL pointer checks.
Change-Id: Id9caef8af0c9d06e40e99ed71db68197fc6cf4f4
Signed-off-by: Shubhashree Dhar <dhar@codeaurora.org>
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
index a46194f..dfb169c7 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1084,6 +1084,7 @@
mutex_unlock(&rot_dev->lock);
error_lock:
kfree(ctx);
+ ctx = NULL;
return ERR_PTR(ret);
}
@@ -1096,10 +1097,18 @@
static int sde_rotator_ctx_release(struct sde_rotator_ctx *ctx,
struct file *file)
{
- struct sde_rotator_device *rot_dev = ctx->rot_dev;
- u32 session_id = ctx->session_id;
+ struct sde_rotator_device *rot_dev;
+ u32 session_id;
struct list_head *curr, *next;
+ if (!ctx) {
+ SDEROT_DBG("ctx is NULL\n");
+ return -EINVAL;
+ }
+
+ rot_dev = ctx->rot_dev;
+ session_id = ctx->session_id;
+
ATRACE_END(ctx->kobj.name);
SDEDEV_DBG(rot_dev->dev, "release s:%d\n", session_id);