e1000e: fix a missing check for return value
Subsystems (2)
PATCH 1/1 e1000e: fix a missing check for return value
The change is based on the issue found by Kangjie Lu <[email protected]> where we not checking the return value of a register read/write which could result in a NULL pointer dereference if the read/write fails.
Since we are only trying to disable the far-end loopback, if the read and write of register fails, we do not want to bail out of the function. We just want to log that it failed to disable and continue on.
--- .../net/ethernet/intel/e1000e/80003es2lan.c | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/e1000e/80003es2lan.c +21 -10
@@ -696,11 +696,15 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw) ret_val =e1000_read_kmrn_reg_80003es2lan (hw,E1000_KMRNCTRLSTA_INBAND_PARAM , &kum_reg_data); -if (ret_val) -return ret_val; - kum_reg_data |=E1000_KMRNCTRLSTA_IBIST_DISABLE ; -e1000_write_kmrn_reg_80003es2lan (hw,E1000_KMRNCTRLSTA_INBAND_PARAM , - kum_reg_data); +if (!ret_val) + kum_reg_data |=E1000_KMRNCTRLSTA_IBIST_DISABLE ; + ret_val =e1000_write_kmrn_reg_80003es2lan (hw, +E1000_KMRNCTRLSTA_INBAND_PARAM , + kum_reg_data); +if (ret_val) +e_dbg ("Error disabling far-end loopback\n" ); + }else +e_dbg ("Error disabling far-end loopback\n" ); ret_val =e1000e_get_auto_rd_done (hw);if (ret_val)
@@ -754,11 +758,18 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)return ret_val;/* Disable IBIST slave mode (far-end loopback) */ -e1000_read_kmrn_reg_80003es2lan (hw,E1000_KMRNCTRLSTA_INBAND_PARAM , - &kum_reg_data); - kum_reg_data |=E1000_KMRNCTRLSTA_IBIST_DISABLE ; -e1000_write_kmrn_reg_80003es2lan (hw,E1000_KMRNCTRLSTA_INBAND_PARAM , - kum_reg_data); + ret_val = +e1000_read_kmrn_reg_80003es2lan (hw,E1000_KMRNCTRLSTA_INBAND_PARAM , + &kum_reg_data); +if (!ret_val) { + kum_reg_data |=E1000_KMRNCTRLSTA_IBIST_DISABLE ; + ret_val =e1000_write_kmrn_reg_80003es2lan (hw, +E1000_KMRNCTRLSTA_INBAND_PARAM , + kum_reg_data); +if (ret_val) +e_dbg ("Error disabling far-end loopback\n" ); + }else +e_dbg ("Error disabling far-end loopback\n" );/* Set the transmit descriptor write-back policy */ reg_data =er32 (TXDCTL (0 ));
Signature · 1 line
2.20.1
PATCH 1/1 e1000e: fix a missing check for return value
Quoted 11 lines · Jeff Kirsher
The change is based on the issue found by Kangjie Lu <[email protected]> where
we not checking the return value of a register read/write which could result
in a NULL pointer dereference if the read/write fails.Since we are only trying to disable the far-end loopback, if the read and write of register fails, we do not want to bail out of the function.
We just want to log that it failed to disable and continue on.
Quoted 7 lines
CC Sasha Neftin <[email protected]>CC Kangjie Lu <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>--- .../net/ethernet/intel/e1000e/80003es2lan.c | 31 +++++++++++++-- ---- 1 file changed, 21 insertions(+), 10 deletions(-)
v2 coming, I fat fingered a typo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20190103/6edd4350/attachment.asc>
Brown
PATCH 1/1 e1000e: fix a missing check for return value
In reply to Jeff KirsherQuoted 17 lines
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Jeff Kirsher
Sent: Thursday, January 3, 2019 3:54 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Kangjie Lu <[email protected]>
Subject: [Intel-wired-lan] [PATCH] e1000e: fix a missing check for return valueThe change is based on the issue found by Kangjie Lu <[email protected]> where
we not checking the return value of a register read/write which could result in a NULL pointer dereference if the read/write fails.Since we are only trying to disable the far-end loopback, if the read and write of register fails, we do not want to bail out of the function. We just want to log that it failed to disable and continue on.
Quoted 7 lines
CC Sasha Neftin <[email protected]>CC Kangjie Lu <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>--- .../net/ethernet/intel/e1000e/80003es2lan.c | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-)