The "CdbMaxPagesEPL" field is 4-bits. The code currently assumes that the value of the field directly determines the number of EPL pages, but values 5 / 6 / 7 correspond to 8 / 12 / 16 EPL pages. Fix the printing of the number of EPL pages by using a translation table and avoid printing the field if the value is reserved (i.e., 8-15). Fixes: fe8e296aa023 ("cmis: Print CDB messaging support advertisement") Reviewed-by: Danielle Ratson Signed-off-by: Ido Schimmel --- cmis.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmis.c b/cmis.c index 16f168a3b1af..da1ced75e4ef 100644 --- a/cmis.c +++ b/cmis.c @@ -924,10 +924,14 @@ static void cmis_show_cdb_mode(const struct cmis_memory_map *map) static void cmis_show_cdb_epl_pages(const struct cmis_memory_map *map) { - __u8 epl_pages = map->page_01h[CMIS_CDB_ADVER_OFFSET] & - CMIS_CDB_ADVER_EPL_MASK; + static const __u8 epl_page_count[] = { 0, 1, 2, 3, 4, 8, 12, 16 }; + __u8 epl = map->page_01h[CMIS_CDB_ADVER_OFFSET] & + CMIS_CDB_ADVER_EPL_MASK; - module_print_any_uint("CDB EPL pages", epl_pages, NULL); + if (epl >= ARRAY_SIZE(epl_page_count)) + return; + + module_print_any_uint("CDB EPL pages", epl_page_count[epl], NULL); } static void cmis_show_cdb_rw_len(const struct cmis_memory_map *map) -- 2.55.0