greybus: fix version check
authorAlex Elder <elder@linaro.org>
Sat, 27 Sep 2014 01:55:34 +0000 (20:55 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 30 Sep 2014 01:07:22 +0000 (18:07 -0700)
When we read a module manifest we are required to verify that its
version is compatible with the version the present code is able
to parse.  All that's required is a check of the major version
number.  If the manifest's major version is greater than the
software, the software can't assume it can parse it.  All new
code must be able to parse all old versions of the format.  And
any difference in minor version is supposed to have no effect
on parsability.

Update the version check to enforce this policy, and reword the
error message to do a better job of explaining the situation.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/core.c

index a240a92..3cc54ed 100644 (file)
@@ -338,8 +338,6 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
        struct greybus_manifest *manifest;
        int retval;
        int overall_size;
-       u8 version_major;
-       u8 version_minor;
 
        /* we have to have at _least_ the manifest header */
        if (size <= sizeof(manifest->header))
@@ -367,16 +365,13 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
                goto error;
        }
 
-       version_major = manifest->header.version_major;
-       version_minor = manifest->header.version_minor;
-
        /* Validate major/minor number */
-       if ((version_major != GREYBUS_VERSION_MAJOR) ||
-           (version_minor != GREYBUS_VERSION_MINOR)) {
+       if (manifest->header.version_major > GREYBUS_VERSION_MAJOR) {
                dev_err(hd->parent,
-                       "Invalid greybus versions, expected %d.%d, got %d.%d\n",
-                       GREYBUS_VERSION_MAJOR, GREYBUS_VERSION_MINOR,
-                       version_major, version_minor);
+                       "Manifest version too new (%hhu.%hhu > %hhu.%hhu)\n",
+                       manifest->header.version_major,
+                       manifest->header.version_minor,
+                       GREYBUS_VERSION_MAJOR, GREYBUS_VERSION_MINOR);
                goto error;
        }