* [PATCH] igc: Do not use link uninitialized in igc_check_for_copper_link
@ 2020-07-16 4:49 Nathan Chancellor
2020-07-16 16:29 ` [Intel-wired-lan] " Neftin, Sasha
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2020-07-16 4:49 UTC (permalink / raw)
To: Jeff Kirsher
Cc: David S. Miller, Jakub Kicinski, intel-wired-lan, netdev,
linux-kernel, clang-built-linux, Nathan Chancellor
Clang warns:
drivers/net/ethernet/intel/igc/igc_mac.c:374:6: warning: variable 'link'
is used uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
if (!mac->get_link_status) {
^~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/igc/igc_mac.c:424:33: note: uninitialized use
occurs here
ret_val = igc_set_ltr_i225(hw, link);
^~~~
drivers/net/ethernet/intel/igc/igc_mac.c:374:2: note: remove the 'if' if
its condition is always false
if (!mac->get_link_status) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/igc/igc_mac.c:367:11: note: initialize the
variable 'link' to silence this warning
bool link;
^
= 0
1 warning generated.
It is not wrong, link is only uninitialized after this through
igc_phy_has_link. Presumably, if we skip the majority of this function
when get_link_status is false, we should skip calling igc_set_ltr_i225
as well. Just directly return 0 in this case, rather than bothering with
adding another label or initializing link in the if statement.
Fixes: 707abf069548 ("igc: Add initial LTR support")
Link: https://github.com/ClangBuiltLinux/linux/issues/1095
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/net/ethernet/intel/igc/igc_mac.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_mac.c b/drivers/net/ethernet/intel/igc/igc_mac.c
index b47e7b0a6398..26e3c56a4a8b 100644
--- a/drivers/net/ethernet/intel/igc/igc_mac.c
+++ b/drivers/net/ethernet/intel/igc/igc_mac.c
@@ -371,10 +371,8 @@ s32 igc_check_for_copper_link(struct igc_hw *hw)
* get_link_status flag is set upon receiving a Link Status
* Change or Rx Sequence Error interrupt.
*/
- if (!mac->get_link_status) {
- ret_val = 0;
- goto out;
- }
+ if (!mac->get_link_status)
+ return 0;
/* First we want to see if the MII Status Register reports
* link. If so, then we want to get the current speed/duplex
base-commit: ca0e494af5edb59002665bf12871e94b4163a257
--
2.28.0.rc0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [Intel-wired-lan] [PATCH] igc: Do not use link uninitialized in igc_check_for_copper_link 2020-07-16 4:49 [PATCH] igc: Do not use link uninitialized in igc_check_for_copper_link Nathan Chancellor @ 2020-07-16 16:29 ` Neftin, Sasha 2020-07-17 2:12 ` Nathan Chancellor 0 siblings, 1 reply; 4+ messages in thread From: Neftin, Sasha @ 2020-07-16 16:29 UTC (permalink / raw) To: Nathan Chancellor, Jeff Kirsher Cc: netdev, linux-kernel, clang-built-linux, intel-wired-lan, Jakub Kicinski, David S. Miller, Lifshits, Vitaly, Neftin, Sasha, Nguyen, Anthony L On 7/16/2020 07:49, Nathan Chancellor wrote: > Clang warns: > Hello Nathan, Thanks for tracking our code.Please, look at https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200709073416.14126-1-sasha.neftin@intel.com/ - I hope this patch already address this Clang warns - please, let me know. > drivers/net/ethernet/intel/igc/igc_mac.c:374:6: warning: variable 'link' > is used uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if (!mac->get_link_status) { > ^~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/intel/igc/igc_mac.c:424:33: note: uninitialized use > occurs here > ret_val = igc_set_ltr_i225(hw, link); > ^~~~ > drivers/net/ethernet/intel/igc/igc_mac.c:374:2: note: remove the 'if' if > its condition is always false > if (!mac->get_link_status) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/intel/igc/igc_mac.c:367:11: note: initialize the > variable 'link' to silence this warning > bool link; > ^ > = 0 > 1 warning generated. > > It is not wrong, link is only uninitialized after this through > igc_phy_has_link. Presumably, if we skip the majority of this function > when get_link_status is false, we should skip calling igc_set_ltr_i225 > as well. Just directly return 0 in this case, rather than bothering with > adding another label or initializing link in the if statement. > > Fixes: 707abf069548 ("igc: Add initial LTR support") > Link: https://github.com/ClangBuiltLinux/linux/issues/1095 > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > --- > drivers/net/ethernet/intel/igc/igc_mac.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/intel/igc/igc_mac.c b/drivers/net/ethernet/intel/igc/igc_mac.c > index b47e7b0a6398..26e3c56a4a8b 100644 > --- a/drivers/net/ethernet/intel/igc/igc_mac.c > +++ b/drivers/net/ethernet/intel/igc/igc_mac.c > @@ -371,10 +371,8 @@ s32 igc_check_for_copper_link(struct igc_hw *hw) > * get_link_status flag is set upon receiving a Link Status > * Change or Rx Sequence Error interrupt. > */ > - if (!mac->get_link_status) { > - ret_val = 0; > - goto out; > - } > + if (!mac->get_link_status) > + return 0; > > /* First we want to see if the MII Status Register reports > * link. If so, then we want to get the current speed/duplex > > base-commit: ca0e494af5edb59002665bf12871e94b4163a257 > Thanks, Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-wired-lan] [PATCH] igc: Do not use link uninitialized in igc_check_for_copper_link 2020-07-16 16:29 ` [Intel-wired-lan] " Neftin, Sasha @ 2020-07-17 2:12 ` Nathan Chancellor 2020-07-19 5:34 ` Neftin, Sasha 0 siblings, 1 reply; 4+ messages in thread From: Nathan Chancellor @ 2020-07-17 2:12 UTC (permalink / raw) To: Neftin, Sasha Cc: Jeff Kirsher, netdev, linux-kernel, clang-built-linux, intel-wired-lan, Jakub Kicinski, David S. Miller, Lifshits, Vitaly, Nguyen, Anthony L On Thu, Jul 16, 2020 at 07:29:03PM +0300, Neftin, Sasha wrote: > On 7/16/2020 07:49, Nathan Chancellor wrote: > > Clang warns: > > > Hello Nathan, > Thanks for tracking our code.Please, look at https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200709073416.14126-1-sasha.neftin@intel.com/ > - I hope this patch already address this Clang warns - please, let me know. I have not explicitly tested it but it seems obvious that it will. Let's go with that. Cheers, Nathan > > drivers/net/ethernet/intel/igc/igc_mac.c:374:6: warning: variable 'link' > > is used uninitialized whenever 'if' condition is true > > [-Wsometimes-uninitialized] > > if (!mac->get_link_status) { > > ^~~~~~~~~~~~~~~~~~~~~ > > drivers/net/ethernet/intel/igc/igc_mac.c:424:33: note: uninitialized use > > occurs here > > ret_val = igc_set_ltr_i225(hw, link); > > ^~~~ > > drivers/net/ethernet/intel/igc/igc_mac.c:374:2: note: remove the 'if' if > > its condition is always false > > if (!mac->get_link_status) { > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > drivers/net/ethernet/intel/igc/igc_mac.c:367:11: note: initialize the > > variable 'link' to silence this warning > > bool link; > > ^ > > = 0 > > 1 warning generated. > > > > It is not wrong, link is only uninitialized after this through > > igc_phy_has_link. Presumably, if we skip the majority of this function > > when get_link_status is false, we should skip calling igc_set_ltr_i225 > > as well. Just directly return 0 in this case, rather than bothering with > > adding another label or initializing link in the if statement. > > > > Fixes: 707abf069548 ("igc: Add initial LTR support") > > Link: https://github.com/ClangBuiltLinux/linux/issues/1095 > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > --- > > drivers/net/ethernet/intel/igc/igc_mac.c | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/net/ethernet/intel/igc/igc_mac.c b/drivers/net/ethernet/intel/igc/igc_mac.c > > index b47e7b0a6398..26e3c56a4a8b 100644 > > --- a/drivers/net/ethernet/intel/igc/igc_mac.c > > +++ b/drivers/net/ethernet/intel/igc/igc_mac.c > > @@ -371,10 +371,8 @@ s32 igc_check_for_copper_link(struct igc_hw *hw) > > * get_link_status flag is set upon receiving a Link Status > > * Change or Rx Sequence Error interrupt. > > */ > > - if (!mac->get_link_status) { > > - ret_val = 0; > > - goto out; > > - } > > + if (!mac->get_link_status) > > + return 0; > > /* First we want to see if the MII Status Register reports > > * link. If so, then we want to get the current speed/duplex > > > > base-commit: ca0e494af5edb59002665bf12871e94b4163a257 > > > Thanks, > Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-wired-lan] [PATCH] igc: Do not use link uninitialized in igc_check_for_copper_link 2020-07-17 2:12 ` Nathan Chancellor @ 2020-07-19 5:34 ` Neftin, Sasha 0 siblings, 0 replies; 4+ messages in thread From: Neftin, Sasha @ 2020-07-19 5:34 UTC (permalink / raw) To: Nathan Chancellor Cc: Jeff Kirsher, netdev, linux-kernel, clang-built-linux, intel-wired-lan, Jakub Kicinski, David S. Miller, Lifshits, Vitaly, Nguyen, Anthony L, Neftin, Sasha On 7/17/2020 05:12, Nathan Chancellor wrote: > On Thu, Jul 16, 2020 at 07:29:03PM +0300, Neftin, Sasha wrote: >> On 7/16/2020 07:49, Nathan Chancellor wrote: >>> Clang warns: >>> >> Hello Nathan, >> Thanks for tracking our code.Please, look at https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200709073416.14126-1-sasha.neftin@intel.com/ >> - I hope this patch already address this Clang warns - please, let me know. > > I have not explicitly tested it but it seems obvious that it will. Let's > go with that. > Good Nathan, let's go with my https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200709073416.14126-1-sasha.neftin@intel.com/ and let me know if warning still generated. Thanks, Sasha > Cheers, > Nathan > >>> drivers/net/ethernet/intel/igc/igc_mac.c:374:6: warning: variable 'link' >>> is used uninitialized whenever 'if' condition is true >>> [-Wsometimes-uninitialized] >>> if (!mac->get_link_status) { >>> ^~~~~~~~~~~~~~~~~~~~~ >>> drivers/net/ethernet/intel/igc/igc_mac.c:424:33: note: uninitialized use >>> occurs here >>> ret_val = igc_set_ltr_i225(hw, link); >>> ^~~~ >>> drivers/net/ethernet/intel/igc/igc_mac.c:374:2: note: remove the 'if' if >>> its condition is always false >>> if (!mac->get_link_status) { >>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> drivers/net/ethernet/intel/igc/igc_mac.c:367:11: note: initialize the >>> variable 'link' to silence this warning >>> bool link; >>> ^ >>> = 0 >>> 1 warning generated. >>> >>> It is not wrong, link is only uninitialized after this through >>> igc_phy_has_link. Presumably, if we skip the majority of this function >>> when get_link_status is false, we should skip calling igc_set_ltr_i225 >>> as well. Just directly return 0 in this case, rather than bothering with >>> adding another label or initializing link in the if statement. >>> >>> Fixes: 707abf069548 ("igc: Add initial LTR support") >>> Link: https://github.com/ClangBuiltLinux/linux/issues/1095 >>> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> >>> --- >>> drivers/net/ethernet/intel/igc/igc_mac.c | 6 ++---- >>> 1 file changed, 2 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/intel/igc/igc_mac.c b/drivers/net/ethernet/intel/igc/igc_mac.c >>> index b47e7b0a6398..26e3c56a4a8b 100644 >>> --- a/drivers/net/ethernet/intel/igc/igc_mac.c >>> +++ b/drivers/net/ethernet/intel/igc/igc_mac.c >>> @@ -371,10 +371,8 @@ s32 igc_check_for_copper_link(struct igc_hw *hw) >>> * get_link_status flag is set upon receiving a Link Status >>> * Change or Rx Sequence Error interrupt. >>> */ >>> - if (!mac->get_link_status) { >>> - ret_val = 0; >>> - goto out; >>> - } >>> + if (!mac->get_link_status) >>> + return 0; >>> /* First we want to see if the MII Status Register reports >>> * link. If so, then we want to get the current speed/duplex >>> >>> base-commit: ca0e494af5edb59002665bf12871e94b4163a257 >>> >> Thanks, >> Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-19 5:37 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-07-16 4:49 [PATCH] igc: Do not use link uninitialized in igc_check_for_copper_link Nathan Chancellor 2020-07-16 16:29 ` [Intel-wired-lan] " Neftin, Sasha 2020-07-17 2:12 ` Nathan Chancellor 2020-07-19 5:34 ` Neftin, Sasha
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).