wifi: ath: Use common kfree() code in 53 functions
Subsystems (5)
PATCH 1/1 wifi: ath: Use common kfree() code in 53 functions
From: Markus Elfring <[email protected]>
Date: Tue, 1 Oct 2024 13:38:27 +0200
Add a label so that a bit of exception handling can be better reused at the end of 53 function implementations.
This issue was transformed by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
--- drivers/net/wireless/ath/ath10k/bmi.c | 7 +- drivers/net/wireless/ath/ath10k/usb.c | 15 +- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 170 +++++++++++--------- drivers/net/wireless/ath/ath11k/wmi.c | 179 ++++++++++++---------- drivers/net/wireless/ath/ath12k/wmi.c | 166 +++++++++++--------- drivers/net/wireless/ath/ath6kl/usb.c | 15 +- 6 files changed, 306 insertions(+), 246 deletions(-)
drivers/net/wireless/ath/ath10k/bmi.c +4 -3
@@ -375,17 +375,18 @@ static int ath10k_bmi_lz_data_large(struct ath10k *ar, const void *buffer, u32 l NULL, NULL);if (ret) {ath10k_warn (ar,"unable to write to the device\n" ); -kfree (cmd); -return ret; + goto free_cmd; } buffer += txlen; length -= txlen; } + ret =0 ; +free_cmd:kfree (cmd); -return 0 ; +return ret; }int ath10k_bmi_lz_data (struct ath10k *ar,const void *buffer,u32 length)
drivers/net/wireless/ath/ath10k/usb.c +8 -7
@@ -504,13 +504,14 @@ static int ath10k_usb_submit_ctrl_out(struct ath10k *ar,if (ret <0 ) {ath10k_warn (ar,"Failed to submit usb control message: %d\n" , ret); -kfree (buf); -return ret; + goto free_buf; } + ret =0 ; +free_buf:kfree (buf); -return 0 ; +return ret; } static int ath10k_usb_submit_ctrl_in(struct ath10k *ar,
@@ -538,15 +539,15 @@ static int ath10k_usb_submit_ctrl_in(struct ath10k *ar,if (ret <0 ) {ath10k_warn (ar,"Failed to read usb control message: %d\n" , ret); -kfree (buf); -return ret; + goto free_buf; }memcpy ((u8 *)data, buf, size); - + ret =0 ; +free_buf:kfree (buf); -return 0 ; +return ret; } static int ath10k_usb_ctrl_msg_exchange(struct ath10k *ar,
drivers/net/wireless/ath/ath10k/wmi-tlv.c +98 -72
420 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/wmi.c +97 -82
431 lines not on this page · raw message
drivers/net/wireless/ath/ath12k/wmi.c +91 -75
390 lines not on this page · raw message
drivers/net/wireless/ath/ath6kl/usb.c +8 -7
@@ -892,13 +892,14 @@ static int ath6kl_usb_submit_ctrl_out(struct ath6kl_usb *ar_usb,if (ret <0 ) {ath6kl_warn ("Failed to submit usb control message: %d\n" , ret); -kfree (buf); -return ret; + goto free_buf; } + ret =0 ; +free_buf:kfree (buf); -return 0 ; +return ret; } static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb,
@@ -924,15 +925,15 @@ static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb,if (ret <0 ) {ath6kl_warn ("Failed to read usb control message: %d\n" , ret); -kfree (buf); -return ret; + goto free_buf; }memcpy ((u8 *) data, buf, size); - + ret =0 ; +free_buf:kfree (buf); -return 0 ; +return ret; } static int ath6kl_usb_ctrl_msg_exchange(struct ath6kl_usb *ar_usb,
--
2.46.1