* [PATCH] gpio: cdev: fix a NULL-pointer dereference with DEBUG enabled @ 2024-02-16 10:59 ` Bartosz Golaszewski 2024-02-16 12:35 ` Marek Szyprowski 0 siblings, 1 reply; 3+ messages in thread From: Bartosz Golaszewski @ 2024-02-16 10:59 UTC (permalink / raw) To: Bartosz Golaszewski, Kent Gibson, Linus Walleij, Paul E . McKenney Cc: linux-gpio, linux-kernel, Bartosz Golaszewski, Marek Szyprowski From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> 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> --- drivers/gpio/gpiolib-cdev.c | 4 ++-- 1 file 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); -- 2.40.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: cdev: fix a NULL-pointer dereference with DEBUG enabled 2024-02-16 10:59 ` [PATCH] gpio: cdev: fix a NULL-pointer dereference with DEBUG enabled Bartosz Golaszewski @ 2024-02-16 12:35 ` Marek Szyprowski 2024-02-16 13:21 ` Bartosz Golaszewski 0 siblings, 1 reply; 3+ messages in thread From: Marek Szyprowski @ 2024-02-16 12:35 UTC (permalink / raw) To: Bartosz Golaszewski, Kent Gibson, Linus Walleij, Paul E . McKenney Cc: linux-gpio, linux-kernel, Bartosz Golaszewski On 16.02.2024 11:59, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > 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> > --- > drivers/gpio/gpiolib-cdev.c | 4 ++-- > 1 file 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); Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: cdev: fix a NULL-pointer dereference with DEBUG enabled 2024-02-16 12:35 ` Marek Szyprowski @ 2024-02-16 13:21 ` Bartosz Golaszewski 0 siblings, 0 replies; 3+ messages in thread From: Bartosz Golaszewski @ 2024-02-16 13:21 UTC (permalink / raw) To: Marek Szyprowski Cc: Kent Gibson, Linus Walleij, Paul E . McKenney, linux-gpio, linux-kernel, Bartosz Golaszewski On Fri, Feb 16, 2024 at 1:35 PM Marek Szyprowski <m.szyprowski@samsung.com> wrote: > > On 16.02.2024 11:59, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > > > 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> Thanks, patch applied. Bart [snip] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-16 13:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20240216105945eucas1p15af2e143fe2090cd33fabb91ff012571@eucas1p1.samsung.com>
2024-02-16 10:59 ` [PATCH] gpio: cdev: fix a NULL-pointer dereference with DEBUG enabled Bartosz Golaszewski
2024-02-16 12:35 ` Marek Szyprowski
2024-02-16 13:21 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).