]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/staging/greybus/manifest.c
greybus: Random spell fixes
[karo-tx-linux.git] / drivers / staging / greybus / manifest.c
index 964f85ed603cb7e8c825a955f8a94a5f977a55eb..28abd2ad395e914da398246df2510622c46c6ae8 100644 (file)
@@ -46,7 +46,7 @@ static void release_manifest_descriptors(void)
 
 /*
  * 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.)
@@ -81,7 +81,7 @@ static int identify_descriptor(struct greybus_descriptor *desc, size_t size)
                }
                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) {
@@ -268,7 +268,7 @@ static bool gb_manifest_parse_module(struct gb_module *gmod,
 
        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);
@@ -289,6 +289,7 @@ static bool gb_manifest_parse_module(struct gb_module *gmod,
 out_err:
        kfree(gmod->product_string);
        gmod->product_string = NULL;
+out_free_vendor_string:
        kfree(gmod->vendor_string);
        gmod->vendor_string = NULL;
 
@@ -329,6 +330,10 @@ bool gb_manifest_parse(struct gb_module *gmod, void *data, size_t size)
        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);