From: Matt Porter Date: Mon, 6 Oct 2014 13:58:44 +0000 (-0400) Subject: greybus: fix manifest parsing problem with descriptor payload X-Git-Tag: v5.15~12752^2~378^2~21^2~2029 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a13e2f68831cba76cb699103b27219649ca6e57;p=platform%2Fkernel%2Flinux-starfive.git greybus: fix manifest parsing problem with descriptor payload The internal struct manifest_desc needs the data payload, rather than the entire descriptor with header to be populated into the data field. Also fix two places where the parser was trying to extract the entire descriptor with header for the data payload field. Signed-off-by: Matt Porter Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c index f0468d7..43ece74 100644 --- a/drivers/staging/greybus/manifest.c +++ b/drivers/staging/greybus/manifest.c @@ -113,7 +113,7 @@ static int identify_descriptor(struct greybus_descriptor *desc, size_t size) return -ENOMEM; descriptor->size = desc_size; - descriptor->data = desc; + descriptor->data = (u8 *)desc + sizeof(*desc_header); descriptor->type = desc_header->type; list_add_tail(&descriptor->links, &manifest_descs); @@ -143,13 +143,11 @@ static char *gb_string_get(u8 string_id) return NULL; list_for_each_entry(descriptor, &manifest_descs, links) { - struct greybus_descriptor *desc; if (descriptor->type != GREYBUS_TYPE_STRING) continue; - desc = descriptor->data; - desc_string = &desc->string; + desc_string = descriptor->data; if (desc_string->id == string_id) { found = true; break; @@ -262,8 +260,7 @@ static u32 gb_manifest_parse_interfaces(struct gb_module *gmod) static bool gb_manifest_parse_module(struct gb_module *gmod, struct manifest_desc *module_desc) { - struct greybus_descriptor *desc = module_desc->data; - struct greybus_descriptor_module *desc_module = &desc->module; + struct greybus_descriptor_module *desc_module = module_desc->data; /* Handle the strings first--they can fail */ gmod->vendor_string = gb_string_get(desc_module->vendor_stringid);