diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2014-05-30 17:13:41 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2014-05-30 17:13:41 +0200 |
commit | 114c1b274edc40e07e9b99a435d26438f5b99943 (patch) | |
tree | 8d17f48960a9d5f21900264d34c6d3d8d62880d3 | |
parent | e13967d6479ead0be90fa241feb52a776b8481dc (diff) |
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 <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | src/mediactl.c | 5 |
1 files changed, 3 insertions, 2 deletions
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; |