diff options
author | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2024-02-16 11:59:30 +0100 |
---|---|---|
committer | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2024-02-16 14:20:07 +0100 |
commit | 91510d5959ad9eac451685e3bfc8385b89c23908 (patch) | |
tree | a11ee7f13d7c279250f4a059a2f4e0b5a1507c21 /drivers/gpio/gpiolib-cdev.c | |
parent | 8ff0d55ba3fb56b69e40c50ff030a77c27a072ca (diff) | |
download | lwn-91510d5959ad9eac451685e3bfc8385b89c23908.tar.gz lwn-91510d5959ad9eac451685e3bfc8385b89c23908.zip |
gpio: cdev: fix a NULL-pointer dereference with DEBUG enabled
We are actually passing the gc pointer to chip_dbg() so we have to
srcu_dereference() it.
Fixes: 8574b5b47610 ("gpio: cdev: use correct pointer accessors with SRCU")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Closes: https://lore.kernel.org/lkml/179caa10-5f86-4707-8bb0-fe1b316326d6@samsung.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'drivers/gpio/gpiolib-cdev.c')
-rw-r--r-- | drivers/gpio/gpiolib-cdev.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 85037fa4925e..f384fa278764 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -2795,8 +2795,8 @@ int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt) return ret; guard(srcu)(&gdev->srcu); - - if (!rcu_access_pointer(gdev->chip)) + gc = srcu_dereference(gdev->chip, &gdev->srcu); + if (!gc) return -ENODEV; chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id); |