rtlwifi: Return correct failure code on error
PATCH v2 1/1 rtlwifi: Return correct failure code on error
Callers of rtl_pci_init expect zero to be returned on error. Returning the error code leads to the data being used when it shouldn't causing, amongst other things, divide by zero panics attempting to use the ring size that is set to zero.
--- drivers/net/wireless/rtlwifi/pci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/rtlwifi/pci.c +1 -1
@@ -1492,7 +1492,7 @@ static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev)if (err) {RT_TRACE (rtlpriv,COMP_ERR ,DBG_EMERG ,"tx ring initialization failed\n" ); -return err; +return 0 ; }return 1 ;
Signature · 1 line
1.7.8.3
Quoted 15 lines · Simon Graham
Callers of
rtl_pci_initexpect zero to be returned on error. Returning the error code leads to the data being used when it shouldn't causing, amongst other things, divide by zero panics attempting to use the ring size that is set to zero.Signed-off-by Simon Graham<[email protected]>--- drivers/net/wireless/rtlwifi/pci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/net/wireless/rtlwifi/pci.c +0
-0
drivers/net/wireless/rtlwifi/pci.c static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev) · line 1498
Quoted 8 lines
drivers/net/wireless/rtlwifi/pci.c +1
-1@@ -1492,7 +1492,7 @@ static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev)if (err) {RT_TRACE (rtlpriv,COMP_ERR ,DBG_EMERG ,"tx ring initialization failed\n" ); -return err; +return 0 ; }return 1 ;
You must have an extreme memory limitation to find all these problems.
As long as you are reworking this section, I would prefer you leave the "return err" as it is now, change the "return 1" to "return 0", and remove the not operator in "err = !rtl_pci_init(hw, pdev);" call of this routine. I just discovered it a few days ago, and it bothers me, but I've been too busy to submit a fix. In addition, these changes will convert rtl_pci_init() into a more normal routine that returns 0 if OK and non-zero on errors.
Larry
Quoted 4 lines
Quoted 1 line
return 1;
You must have an extreme memory limitation to find all these problems.
As part of system testing we do
Quoted 1 line
As long as you are reworking this section, I would prefer you leave
the
Quoted 6 lines
"return
err" as it is now, change the "return 1" to "return 0", and remove the not
operator in "err = !rtl_pci_init(hw, pdev);" call of this routine. I just
discovered it a few days ago, and it bothers me, but I've been too
busy
Quoted 5 lines
to
submit a fix. In addition, these changes will convertrtl_pci_init()into a more
normal routine that returns 0 if OK and non-zero on errors.
OK - I'll do that tomorrow and resubmit (hopefully correctly this time!)
Quoted 1 line
Larry