aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/vc04_services/bcm2835-camera
diff options
context:
space:
mode:
authorAishwarya Pant <aishpant@gmail.com>2017-03-10 00:30:58 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-10 10:13:07 +0100
commita1d76d7a3cb2ba10ee43da559f6a54cc9dd2d26c (patch)
treed127611410bec6ab3e3ee3914e4c952ecda34afc /drivers/staging/vc04_services/bcm2835-camera
parentstaging: bcm2835-camera: remove depends on ARM (diff)
downloadlinux-dev-a1d76d7a3cb2ba10ee43da559f6a54cc9dd2d26c.tar.xz
linux-dev-a1d76d7a3cb2ba10ee43da559f6a54cc9dd2d26c.zip
staging: bcm2835-camera: add check to avoid null pointer dereference
This patch adds checks after memory allocation to avoid possible null pointer dereferences. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vc04_services/bcm2835-camera')
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index 5a431bcc711a..436e489713e5 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -260,8 +260,11 @@ get_msg_context(struct vchiq_mmal_instance *instance)
/* todo: should this be allocated from a pool to avoid kmalloc */
msg_context = kmalloc(sizeof(*msg_context), GFP_KERNEL);
- memset(msg_context, 0, sizeof(*msg_context));
+ if (!msg_context)
+ return NULL;
+
+ memset(msg_context, 0, sizeof(*msg_context));
msg_context->instance = instance;
msg_context->handle =
mmal_context_map_create_handle(&instance->context_map,
@@ -2015,8 +2018,11 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
}
instance = kmalloc(sizeof(*instance), GFP_KERNEL);
- memset(instance, 0, sizeof(*instance));
+ if (!instance)
+ return -ENOMEM;
+
+ memset(instance, 0, sizeof(*instance));
mutex_init(&instance->vchiq_mutex);
mutex_init(&instance->bulk_mutex);