From 114c1b274edc40e07e9b99a435d26438f5b99943 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 30 May 2014 17:13:41 +0200 Subject: Fix uninitialized pointer dereference in media_device_add_entity When the entity being added has the default flag set, the function tries to set the entity as the default entity for its type by storing the entity pointer in the appropriate default entity field. If the entity type isn't recognized, the default entity pointer is left uninitialized, leading to a crash. Fix it. Signed-off-by: Laurent Pinchart --- src/mediactl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mediactl.c b/src/mediactl.c index 6e2d29a..1f92987 100644 --- a/src/mediactl.c +++ b/src/mediactl.c @@ -717,7 +717,7 @@ int media_device_add_entity(struct media_device *media, const struct media_entity_desc *desc, const char *devnode) { - struct media_entity **defent; + struct media_entity **defent = NULL; struct media_entity *entity; unsigned int size; @@ -763,7 +763,8 @@ int media_device_add_entity(struct media_device *media, if (desc->flags & MEDIA_ENT_FL_DEFAULT) { entity->info.flags |= MEDIA_ENT_FL_DEFAULT; - *defent = entity; + if (defent) + *defent = entity; } return 0; -- cgit v1.2.3