diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-11-15 11:30:44 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-11-15 11:42:25 +0100 |
commit | ac40b79f002a2315f909548614ccd2d408da25b7 (patch) | |
tree | 5ece0730097dff98c607e5d6b5fb50d9bc4d8f4d | |
parent | a6ec4a37028952ffd6e62eb52648cf66248eb519 (diff) |
media: Fix valgrind warnings
valgrind has no way to know that the kernel will fill links and pads
arrays passed to an ioctl through __user pointers. Allocate the arrays
with calloc() to make sure they get initialized. This also fixes the
potential integer overflow.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
-rw-r--r-- | src/mediactl.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mediactl.c b/src/mediactl.c index 14cff30..46562de 100644 --- a/src/mediactl.c +++ b/src/mediactl.c @@ -206,8 +206,8 @@ static int media_enum_links(struct media_device *media) unsigned int i; links.entity = entity->info.id; - links.pads = malloc(entity->info.pads * sizeof(struct media_pad_desc)); - links.links = malloc(entity->info.links * sizeof(struct media_link_desc)); + links.pads = calloc(entity->info.pads, sizeof(struct media_pad_desc)); + links.links = calloc(entity->info.links, sizeof(struct media_link_desc)); if (ioctl(media->fd, MEDIA_IOC_ENUM_LINKS, &links) < 0) { media_dbg(media, |