]> git.baikalelectronics.ru Git - kernel.git/commit
gpio: gpiolib-of: Fix refcount bugs in of_mm_gpiochip_add_data()
authorLiang He <windhl@126.com>
Mon, 11 Jul 2022 12:52:38 +0000 (20:52 +0800)
committerBartosz Golaszewski <brgl@bgdev.pl>
Tue, 19 Jul 2022 07:57:41 +0000 (09:57 +0200)
commit72dfd84a2345b35a5ee82ef12ca505b559ef4608
tree82f064f8c5ba32e80a673bd4827e6f10aeda8274
parent51712038897197045793456dbc28bbfe72b9972b
gpio: gpiolib-of: Fix refcount bugs in of_mm_gpiochip_add_data()

We should use of_node_get() when a new reference of device_node
is created. It is noted that the old reference stored in
'mm_gc->gc.of_node' should also be decreased.

This patch is based on the fact that there is a call site in function
'qe_add_gpiochips()' of src file 'drivers\soc\fsl\qe\gpio.c'. In this
function, of_mm_gpiochip_add_data() is contained in an iteration of
for_each_compatible_node() which will automatically increase and
decrease the refcount. So we need additional of_node_get() for the
reference escape in of_mm_gpiochip_add_data().

Fixes: bfc6548d945f ("of/gpio: Kill of_gpio_chip and add members directly to gpio_chip")
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
drivers/gpio/gpiolib-of.c