be2net: Missing byteswap in be_get_fw_log_level causes oops on PowerPC
Subsystems (3)
PATCH 1/1 be2net: Missing byteswap in be_get_fw_log_level causes oops on PowerPC
We are seeing an oops in be_get_fw_log_level on ppc64 where we walk off the end of memory.
commit 941a77d582c8 (be2net: Fix to allow get/set of debug levels in the firmware.) requires byteswapping of num_modes and num_modules.
---
drivers/net/ethernet/emulex/benet/be_ethtool.c +3 -2
@@ -910,8 +910,9 @@ static void be_set_fw_log_level(struct be_adapter *adapter, u32 level)if (!status) { cfgs = (struct be_fat_conf_params *)(extfat_cmd.va +sizeof (struct be_cmd_resp_hdr )); -for (i =0 ; i < cfgs->num_modules; i++) { -for (j =0 ; j < cfgs->module[i].num_modes; j++) { +for (i =0 ; i <le32_to_cpu (cfgs->num_modules); i++) { +u32 num_modes =le32_to_cpu (cfgs->module[i].num_modes); +for (j =0 ; j < num_modes; j++) {if (cfgs->module[i].trace_lvl[j].mode ==MODE_UART ) cfgs->module[i].trace_lvl[j].dbg_lvl =
drivers/net/ethernet/emulex/benet/be_main.c +1 -1
@@ -3479,7 +3479,7 @@ u32 be_get_fw_log_level(struct be_adapter *adapter)if (!status) { cfgs = (struct be_fat_conf_params *)(extfat_cmd.va +sizeof (struct be_cmd_resp_hdr )); -for (j =0 ; j < cfgs->module[0 ].num_modes; j++) { +for (j =0 ; j <le32_to_cpu (cfgs->module[0 ].num_modes); j++) {if (cfgs->module[0 ].trace_lvl[j].mode ==MODE_UART ) level = cfgs->module[0 ].trace_lvl[j].dbg_lvl; }
Quoted 11 lines
-----Original Message-----
From: Anton Blanchard [mailto:[email protected]]We are seeing an oops in
be_get_fw_log_levelon ppc64 where we walk off the end of memory.commit
941a77d582c8(be2net: Fix to allow get/set of debug levels in the firmware.) requires byteswapping ofnum_modesandnum_modules.Cc [email protected] # 3.5+Signed-off-by Anton Blanchard <[email protected]>
Thanks for the fix!
Quoted 35 lines
---
drivers/net/ethernet/emulex/benet/be_ethtool.c +3
-2@@ -910,8 +910,9 @@ static void be_set_fw_log_level(struct be_adapter *adapter, u32 level)if (!status) { cfgs = (struct be_fat_conf_params *)(extfat_cmd.va +sizeof (struct be_cmd_resp_hdr )); -for (i =0 ; i < cfgs->num_modules; i++) { -for (j =0 ; j < cfgs->module[i].num_modes; j++) { +for (i =0 ; i <le32_to_cpu (cfgs->num_modules); i++) { +u32 num_modes =le32_to_cpu (cfgs- >module[i].num_modes); +for (j =0 ; j < num_modes; j++) { if (cfgs->module[i].trace_lvl[j].mode ==MODE_UART) cfgs->module[i].trace_lvl[j].dbg_lvl =drivers/net/ethernet/emulex/benet/be_main.c +1
-1@@ -3479,7 +3479,7 @@ u32 be_get_fw_log_level(struct be_adapter *adapter)if (!status) { cfgs = (struct be_fat_conf_params *)(extfat_cmd.va +sizeof (struct be_cmd_resp_hdr )); -for (j =0 ; j < cfgs->module[0 ].num_modes; j++) { +for (j =0 ; j <le32_to_cpu (cfgs->module[0 ].num_modes); j++) {if (cfgs->module[0 ].trace_lvl[j].mode ==MODE_UART ) level = cfgs->module[0 ].trace_lvl[j].dbg_lvl; }
From: Anton Blanchard <[email protected]>
Date: Wed, 25 Jul 2012 11:05:25 +1000
Quoted 9 lines
We are seeing an oops in
be_get_fw_log_levelon ppc64 where we walk off the end of memory.commit
941a77d582c8(be2net: Fix to allow get/set of debug levels in the firmware.) requires byteswapping ofnum_modesandnum_modules.Cc [email protected] # 3.5+Signed-off-by Anton Blanchard <[email protected]>
Applied.