mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
greybus: manifest: use size_t for a size variable
In identify_descriptor(), the variable desc_size represents the size of a memory object. So change its type from int to size_t. The return value for this function can be desc_size cast to int. One can verify by inspection this will never exceed INT_MAX. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
parent
973ccfd626
commit
d8187aa224
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Greybus module manifest parsing
|
||||
*
|
||||
* Copyright 2014 Google Inc.
|
||||
* Copyright 2014 Linaro Ltd.
|
||||
* Copyright 2014-2015 Google Inc.
|
||||
* Copyright 2014-2015 Linaro Ltd.
|
||||
*
|
||||
* Released under the GPLv2 only.
|
||||
*/
|
||||
@ -79,7 +79,7 @@ static int identify_descriptor(struct gb_interface *intf,
|
||||
{
|
||||
struct greybus_descriptor_header *desc_header = &desc->header;
|
||||
struct manifest_desc *descriptor;
|
||||
int desc_size;
|
||||
size_t desc_size;
|
||||
size_t expected_size;
|
||||
|
||||
if (size < sizeof(*desc_header)) {
|
||||
@ -87,8 +87,8 @@ static int identify_descriptor(struct gb_interface *intf,
|
||||
return -EINVAL; /* Must at least have header */
|
||||
}
|
||||
|
||||
desc_size = (int)le16_to_cpu(desc_header->size);
|
||||
if ((size_t)desc_size > size) {
|
||||
desc_size = le16_to_cpu(desc_header->size);
|
||||
if (desc_size > size) {
|
||||
pr_err("descriptor too big\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -119,7 +119,7 @@ static int identify_descriptor(struct gb_interface *intf,
|
||||
}
|
||||
|
||||
if (desc_size < expected_size) {
|
||||
pr_err("%s descriptor too small (%u < %zu)\n",
|
||||
pr_err("%s descriptor too small (%zu < %zu)\n",
|
||||
get_descriptor_type_string(desc_header->type),
|
||||
desc_size, expected_size);
|
||||
return -EINVAL;
|
||||
@ -134,6 +134,8 @@ static int identify_descriptor(struct gb_interface *intf,
|
||||
descriptor->type = desc_header->type;
|
||||
list_add_tail(&descriptor->links, &intf->manifest_descs);
|
||||
|
||||
/* desc_size is is positive and is known to fit in a signed int */
|
||||
|
||||
return desc_size;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user