Compare
bd22f7e63509fa758cf500d9af3e88a3d3df96be..aaabefc79b0ff0018e8e3832169bbe359d0551fc
i2c: viai2c-wmt: Fix clock leak in wmt_i2c_probe()
In wmt_i2c_probe(), i2c->clk is acquired using of_clk_get(). If any
subsequent operation fails or when the module is unloaded, the clock
reference count is never decremented via clk_put(), leading to a
resource leak.
Switch to devm_clk_get() so that the clock is automatically managed
and released.
Fixes: 560746eb79d3 ("i2c: vt8500: Add support for I2C bus on Wondermedia SoCs")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20260916070631.1965713-1-vulab@iscas.ac.cn
Wentao Liang <vulab@iscas.ac.cn> · 2026-09-16 07:06 UTC · committed by Andi Shyti
4 files changed,
+6
−16
- drivers/gpio/gpio-nct6694.c
- drivers/gpio/gpiolib-shared.c
- drivers/i2c/busses/i2c-viai2c-wmt.c
- tools/gpio/Makefile
modified drivers/gpio/gpio-nct6694.c
| @@ -444,7 +444,7 @@ static int nct6694_gpio_probe(struct platform_device *pdev) | |||
| 444 | 444 | data->gpio.set_config = nct6694_set_config; | |
| 445 | 445 | data->gpio.init_valid_mask = nct6694_init_valid_mask; | |
| 446 | 446 | data->gpio.base = -1; | |
| 447 | - | data->gpio.can_sleep = true; | |
| 447 | + | data->gpio.can_sleep = false; | |
| 448 | 448 | data->gpio.owner = THIS_MODULE; | |
| 449 | 449 | data->gpio.ngpio = NCT6694_NR_GPIO; | |
| 450 | 450 | ||
modified drivers/i2c/busses/i2c-viai2c-wmt.c
| @@ -116,7 +116,7 @@ static int wmt_i2c_probe(struct platform_device *pdev) | |||
| 116 | 116 | if (err) | |
| 117 | 117 | return err; | |
| 118 | 118 | ||
| 119 | - | i2c->clk = of_clk_get(np, 0); | |
| 119 | + | i2c->clk = devm_clk_get(&pdev->dev, NULL); | |
| 120 | 120 | if (IS_ERR(i2c->clk)) | |
| 121 | 121 | return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk), | |
| 122 | 122 | "unable to request clock\n"); | |
modified tools/gpio/Makefile
| @@ -7,13 +7,7 @@ bindir ?= /usr/bin | |||
| 7 | 7 | # isn't set and when invoked from selftests build, where srctree | |
| 8 | 8 | # is set to ".". building_out_of_srctree is undefined for in srctree | |
| 9 | 9 | # builds | |
| 10 | - | ifeq ($(srctree),) | |
| 11 | - | update_srctree := 1 | |
| 12 | - | endif | |
| 13 | 10 | ifndef building_out_of_srctree | |
| 14 | - | update_srctree := 1 | |
| 15 | - | endif | |
| 16 | - | ifeq ($(update_srctree),1) | |
| 17 | 11 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) | |
| 18 | 12 | srctree := $(patsubst %/,%,$(dir $(srctree))) | |
| 19 | 13 | endif | |