* [PATCH] net: 80003es2lan: fix a missing check of read failure
@ 2018-12-20 21:23 ` Kangjie Lu
0 siblings, 0 replies; 5+ messages in thread
From: Kangjie Lu @ 2018-12-20 21:23 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Jeff Kirsher, David S. Miller, intel-wired-lan, netdev,
linux-kernel
When e1000_read_kmrn_reg_80003es2lan() fails, "kum_reg_data" is
uninitialized and may contain random value. However, it is further
used in the following execution, which will lead to undefined
behaviors.
The fix checks the failure of e1000_read_kmrn_reg_80003es2lan() and
returns with its error code if it fails.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/intel/e1000e/80003es2lan.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
index 257bd59bc9c6..8a6f8e80e062 100644
--- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
+++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
@@ -754,8 +754,11 @@ 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);
+ 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);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Intel-wired-lan] [PATCH] net: 80003es2lan: fix a missing check of read failure
@ 2018-12-20 21:23 ` Kangjie Lu
0 siblings, 0 replies; 5+ messages in thread
From: Kangjie Lu @ 2018-12-20 21:23 UTC (permalink / raw)
To: intel-wired-lan
When e1000_read_kmrn_reg_80003es2lan() fails, "kum_reg_data" is
uninitialized and may contain random value. However, it is further
used in the following execution, which will lead to undefined
behaviors.
The fix checks the failure of e1000_read_kmrn_reg_80003es2lan() and
returns with its error code if it fails.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/intel/e1000e/80003es2lan.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
index 257bd59bc9c6..8a6f8e80e062 100644
--- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
+++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
@@ -754,8 +754,11 @@ 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);
+ 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);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: 80003es2lan: fix a missing check of read failure
2018-12-20 21:23 ` [Intel-wired-lan] " Kangjie Lu
@ 2018-12-21 19:18 ` Jeff Kirsher
-1 siblings, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2018-12-21 19:18 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, David S. Miller, intel-wired-lan, netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 774 bytes --]
On Thu, 2018-12-20 at 15:23 -0600, Kangjie Lu wrote:
> When e1000_read_kmrn_reg_80003es2lan() fails, "kum_reg_data" is
> uninitialized and may contain random value. However, it is further
> used in the following execution, which will lead to undefined
> behaviors.
> The fix checks the failure of e1000_read_kmrn_reg_80003es2lan() and
> returns with its error code if it fails.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/intel/e1000e/80003es2lan.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
This is a good catch, although we do not want to exit out on failure. I
have an alternative patch to resolve both issues, which I will submit later
today. Just need to finish holiday shopping for my wife... :-)
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Intel-wired-lan] [PATCH] net: 80003es2lan: fix a missing check of read failure
@ 2018-12-21 19:18 ` Jeff Kirsher
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2018-12-21 19:18 UTC (permalink / raw)
To: intel-wired-lan
On Thu, 2018-12-20 at 15:23 -0600, Kangjie Lu wrote:
> When e1000_read_kmrn_reg_80003es2lan() fails, "kum_reg_data" is
> uninitialized and may contain random value. However, it is further
> used in the following execution, which will lead to undefined
> behaviors.
> The fix checks the failure of e1000_read_kmrn_reg_80003es2lan() and
> returns with its error code if it fails.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/intel/e1000e/80003es2lan.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
This is a good catch, although we do not want to exit out on failure. I
have an alternative patch to resolve both issues, which I will submit later
today. Just need to finish holiday shopping for my wife... :-)
-------------- 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/20181221/f98519dc/attachment.asc>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Intel-wired-lan] [PATCH] net: 80003es2lan: fix a missing check of read failure
2018-12-21 19:18 ` [Intel-wired-lan] " Jeff Kirsher
(?)
@ 2018-12-21 19:21 ` Kangjie Lu
-1 siblings, 0 replies; 5+ messages in thread
From: Kangjie Lu @ 2018-12-21 19:21 UTC (permalink / raw)
To: intel-wired-lan
Sounds good. Look forward to your alternative patch. Enjoy your shopping.
On Fri, Dec 21, 2018 at 1:19 PM Jeff Kirsher <jeffrey.t.kirsher@intel.com>
wrote:
> On Thu, 2018-12-20 at 15:23 -0600, Kangjie Lu wrote:
> > When e1000_read_kmrn_reg_80003es2lan() fails, "kum_reg_data" is
> > uninitialized and may contain random value. However, it is further
> > used in the following execution, which will lead to undefined
> > behaviors.
> > The fix checks the failure of e1000_read_kmrn_reg_80003es2lan() and
> > returns with its error code if it fails.
> >
> > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > ---
> > drivers/net/ethernet/intel/e1000e/80003es2lan.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
>
> This is a good catch, although we do not want to exit out on failure. I
> have an alternative patch to resolve both issues, which I will submit later
> today. Just need to finish holiday shopping for my wife... :-)
>
--
Kangjie Lu
Assistant Professor
Department of Computer Science and Engineering
University of Minnesota
Personal homepage <https://www-users.cs.umn.edu/~kjlu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20181221/798b1ee4/attachment.html>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-12-21 19:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 21:23 [PATCH] net: 80003es2lan: fix a missing check of read failure Kangjie Lu
2018-12-20 21:23 ` [Intel-wired-lan] " Kangjie Lu
2018-12-21 19:18 ` Jeff Kirsher
2018-12-21 19:18 ` [Intel-wired-lan] " Jeff Kirsher
2018-12-21 19:21 ` Kangjie Lu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.