OSDN Git Service

greybus: manifest: Account for padding in string descriptor
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 28 Apr 2015 14:21:35 +0000 (19:51 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 29 Apr 2015 13:53:18 +0000 (15:53 +0200)
String descriptors are padded towards the end to align them to 4 byte
boundaries. Take that into account while calculating expected size.

Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/manifest.c

index d6cafeb..1253663 100644 (file)
@@ -100,6 +100,9 @@ static int identify_descriptor(struct gb_interface *intf,
        case GREYBUS_TYPE_STRING:
                expected_size += sizeof(struct greybus_descriptor_string);
                expected_size += desc->string.length;
+
+               /* String descriptors are padded to 4 byte boundaries */
+               expected_size = ALIGN(expected_size, 4);
                break;
        case GREYBUS_TYPE_INTERFACE:
                expected_size += sizeof(struct greybus_descriptor_interface);