/*
* Validate the given descriptor. Its reported size must fit within
- * the number of bytes reamining, and it must have a recognized
+ * the number of bytes remaining, and it must have a recognized
* type. Check that the reported size is at least as big as what
* we expect to see. (It could be bigger, perhaps for a new version
* of the format.)
}
break;
case GREYBUS_TYPE_STRING:
- expected_size = sizeof(struct greybus_descriptor_header);
+ expected_size = sizeof(*desc_header);
expected_size += sizeof(struct greybus_descriptor_string);
expected_size += (size_t)desc->string.length;
if (desc_size < expected_size) {
gmod->product_string = gb_string_get(desc_module->product_stringid);
if (IS_ERR(gmod->product_string)) {
- goto out_err;
+ goto out_free_vendor_string;
}
gmod->vendor = le16_to_cpu(desc_module->vendor);
out_err:
kfree(gmod->product_string);
gmod->product_string = NULL;
+out_free_vendor_string:
kfree(gmod->vendor_string);
gmod->vendor_string = NULL;
u32 found = 0;
bool result;
+ /* Manifest descriptor list should be empty here */
+ if (WARN_ON(!list_empty(&manifest_descs)))
+ return false;
+
/* we have to have at _least_ the manifest header */
if (size <= sizeof(manifest->header)) {
pr_err("short manifest (%zu)\n", size);