summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-11-14 03:19:10 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-11-15 11:41:01 +0100
commite0f7ed35d188b792269f041f053ae182999e03a9 (patch)
tree4fab8a72815ca594e0234eea0513ad4e30058b70
parent2d6416324ca2dd1b8c885460e9f3944ba78e156e (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>
-rw-r--r--isp/media.c4
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",