From: Alex Elder Date: Sat, 27 Sep 2014 01:55:34 +0000 (-0500) Subject: greybus: fix version check X-Git-Tag: v4.14-rc1~2366^2~378^2~21^2~2074 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01e8280150a2ef330f082a996479b96d75164353;p=platform%2Fkernel%2Flinux-rpi.git 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: Alex Elder Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index a240a92..3cc54ed 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -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; }