Commit 01e82801 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: fix version check

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: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 72b0ffc0
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment