Hi,
This patch is wrong, please ignore it,
Dafna
On 11/18/19 1:55 PM, Dafna Hirschfeld wrote:
In the function media_enum_links, the links and pads pointers
should be allocated according to number of pads and links of
the entity. Currently they are allocated to only one element.
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@xxxxxxxxxxxxx>
---
utils/media-ctl/libmediactl.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 1fd6525b..d9a30b01 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -325,11 +325,15 @@ static int media_enum_links(struct media_device *media)
for (id = 1; id <= media->entities_count; id++) {
struct media_entity *entity = &media->entities[id - 1];
struct media_links_enum links = { 0 };
+ unsigned int pads_num = entity->info.pads;
+ unsigned int links_num = entity->info.links;
unsigned int i;
links.entity = entity->info.id;
- links.pads = calloc(entity->info.pads, sizeof(struct media_pad_desc));
- links.links = calloc(entity->info.links, sizeof(struct media_link_desc));
+ links.pads = calloc(entity->info.pads,
+ pads_num * sizeof(struct media_pad_desc));
+ links.links = calloc(entity->info.links,
+ links_num * sizeof(struct media_link_desc));
if (ioctl(media->fd, MEDIA_IOC_ENUM_LINKS, &links) < 0) {
ret = -errno;
@@ -341,13 +345,13 @@ static int media_enum_links(struct media_device *media)
return ret;
}
- for (i = 0; i < entity->info.pads; ++i) {
+ for (i = 0; i < pads_num; ++i) {
entity->pads[i].entity = entity;
entity->pads[i].index = links.pads[i].index;
entity->pads[i].flags = links.pads[i].flags;
}
- for (i = 0; i < entity->info.links; ++i) {
+ for (i = 0; i < links_num; ++i) {
struct media_link_desc *link = &links.links[i];
struct media_link *fwdlink;
struct media_link *backlink;