diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-11-14 03:19:10 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-11-15 11:41:01 +0100 |
commit | e0f7ed35d188b792269f041f053ae182999e03a9 (patch) | |
tree | 4fab8a72815ca594e0234eea0513ad4e30058b70 /isp | |
parent | 2d6416324ca2dd1b8c885460e9f3944ba78e156e (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>
Diffstat (limited to 'isp')
-rw-r--r-- | isp/media.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/isp/media.c b/isp/media.c index 94efab8..edf74e4 100644 --- a/isp/media.c +++ b/isp/media.c @@ -192,8 +192,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) { printf("%s: Unable to enumerate pads and links (%s).\n", |