From 5e883a1186481eb29d947d1453916c702b6bcd92 Mon Sep 17 00:00:00 2001 From: Todor Tomov Date: Tue, 4 Jan 2011 11:49:56 +0200 Subject: media.c: fix NULL pointer dereference in media_enum_links() Do not dereference source and sink in media_enum_links() if one of them is NULL. Signed-off-by: Todor Tomov --- media.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/media.c b/media.c index 75ca24c..d5d98de 100644 --- a/media.c +++ b/media.c @@ -424,11 +424,11 @@ static int media_enum_links(struct media_device *media) id, i, link->source.entity, link->source.index, link->sink.entity, link->sink.index); ret = -EINVAL; + } else { + entity->links[i].source = &source->pads[link->source.index]; + entity->links[i].sink = &sink->pads[link->sink.index]; + entity->links[i].flags = links.links[i].flags; } - - entity->links[i].source = &source->pads[link->source.index]; - entity->links[i].sink = &sink->pads[link->sink.index]; - entity->links[i].flags = links.links[i].flags; } free(links.pads); -- cgit v1.2.3