greybus: core: verify major/minor number of greybus protocol
authorGreg Kroah-Hartman <greg@kroah.com>
Sun, 14 Sep 2014 00:28:19 +0000 (17:28 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Sun, 14 Sep 2014 00:28:19 +0000 (17:28 -0700)
drivers/staging/greybus/core.c

index 1d9efd4b5f590c095e8966793d978d920604d087..bad40bafae4c23cd6580f9a90c1af4a82eec663e 100644 (file)
@@ -385,7 +385,15 @@ struct greybus_device *greybus_new_module(struct device *parent,
        version_major = manifest->header.version_major;
        version_minor = manifest->header.version_minor;
 
-       // FIXME - check version major/minor here!
+       /* Validate major/minor number */
+       if ((version_major != GREYBUS_VERSION_MAJOR) ||
+           (version_minor != GREYBUS_VERSION_MINOR)) {
+               dev_err(parent,
+                       "Invalid greybus versions, expected %d.%d, got %d.%d\n",
+                       GREYBUS_VERSION_MAJOR, GREYBUS_VERSION_MINOR,
+                       version_major, version_minor);
+               goto error;
+       }
 
        size -= sizeof(manifest->header);
        data += sizeof(manifest->header);