This fixes a divide by zero which happened when an array,
without an explicit entry count (ultimately calculated from
the value in the descriptor data's bLength field) was used
on field with a variable size.

The solultion is to use the get_entry_size() function on
the array entry, which can get the entry size from a
referenced field.

Signed-off-by: Michael Drake <michael.dr...@codethink.co.uk>
---
 desc-dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/desc-dump.c b/desc-dump.c
index 0df0e00..0adf39d 100644
--- a/desc-dump.c
+++ b/desc-dump.c
@@ -423,7 +423,7 @@ static unsigned int get_array_entry_count(
                        }
                }
 
-               entries = size / array_entry->size;
+               entries = size / get_entry_size(buf, desc, array_entry);
        }
 
        return entries;
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to