[PATCH 140/342] Staging: w35und: more simplify hal_init_hardware() error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Pekka Enberg <penberg at cs.helsinki.fi>

Impact: fix, cleanup

If initialization in hal_init_hardware() fails, we call hal_halt() to
clean up and release resource. However, hal_halt() will attempt to
call del_timer_sync() on ->LEDTimer on "stage 3" although it's not
initialized at that point. Fix that up by simplifying error handling
logic in hal_init_hardware() with gotos.

Acked-by: Pavel Machek <pavel at ucw.cz>
Signed-off-by: Pekka Enberg <penberg at cs.helsinki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
---
 drivers/staging/winbond/wbusb.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index 4ce2e5a..fc2566a 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -488,15 +488,15 @@ static int hal_init_hardware(struct ieee80211_hw *hw)
 
 	pHwData->InitialResource = 1;
 	if (!Wb35Reg_initial(pHwData))
-		goto error;
+		goto error_reg_destroy;
 
 	pHwData->InitialResource = 2;
 	if (!Wb35Tx_initial(pHwData))
-		goto error;
+		goto error_tx_destroy;
 
 	pHwData->InitialResource = 3;
 	if (!Wb35Rx_initial(pHwData))
-		goto error;
+		goto error_rx_destroy;
 
 	pHwData->InitialResource = 4;
 	init_timer(&pHwData->LEDTimer);
@@ -522,7 +522,13 @@ static int hal_init_hardware(struct ieee80211_hw *hw)
 
 	return 0;
 
-error:
+error_rx_destroy:
+	Wb35Rx_destroy(pHwData);
+error_tx_destroy:
+	Wb35Tx_destroy(pHwData);
+error_reg_destroy:
+	Wb35Reg_destroy(pHwData);
+
 	pHwData->SurpriseRemove = 1;
 	return -EINVAL;
 }
@@ -617,11 +623,8 @@ static int wb35_hw_init(struct ieee80211_hw *hw)
 	hal_driver_init_OK(pHwData) = 1; // Notify hal that the driver is ready now.
 	//set a tx power for reference.....
 //	sme_set_tx_power_level(priv, 12);	FIXME?
-	return 0;
 
 error:
-	hal_halt(pHwData, NULL);
-
 	return err;
 }
 
-- 
1.6.3.2



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux