diff mbox series

net: rfkill: gpio: Add check for clk_enable()

Message ID 20241107210155.1383802-1-zmw12306@gmail.com
State Superseded
Headers show
Series net: rfkill: gpio: Add check for clk_enable() | expand

Commit Message

Mingwei Zheng Nov. 7, 2024, 9:01 p.m. UTC
Add check for the return value of clk_enable() to catch the potential
expection.

Fixes: 7176ba23f8b5 ("net: rfkill: add generic gpio rfkill driver")
Signed-off-by: Mingwei Zheng <zmw12306@gmail.com>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
 net/rfkill/rfkill-gpio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Johannes Berg Nov. 7, 2024, 9:13 p.m. UTC | #1
On Thu, 2024-11-07 at 16:01 -0500, Mingwei Zheng wrote:
> Add check for the return value of clk_enable() to catch the potential
> expection.

"exception"? but we don't have exceptions? "error"?

johannes
diff mbox series

Patch

diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index c268c2b011f4..a87bb99231a6 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -31,9 +31,13 @@  struct rfkill_gpio_data {
 static int rfkill_gpio_set_power(void *data, bool blocked)
 {
 	struct rfkill_gpio_data *rfkill = data;
+	int ret;
 
-	if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
-		clk_enable(rfkill->clk);
+	if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled) {
+		ret = clk_enable(rfkill->clk);
+		if (!ret)
+			return ret;
+	}
 
 	gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked);
 	gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked);