gpio: cdev: avoid uninitialized variable dereference
PATCH 1/1 gpio: cdev: avoid uninitialized variable dereference
From: Arnd Bergmann <[email protected]>
The 'gc' variable is never set before it gets printed:
drivers/gpio/gpiolib-cdev.c:2802:11: error: variable 'gc' is uninitialized when used here [-Werror,-Wuninitialized]
2802 | chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id);
| ^~drivers/gpio/gpiolib.h:277:11: note: expanded from macro 'chip_dbg'
277 | dev_dbg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__)
| ^~
Use dev_dbg() directly.
--- drivers/gpio/gpiolib-cdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpiolib-cdev.c +1 -2
@@ -2783,7 +2783,6 @@ static const struct file_operations gpio_fileops = {int gpiolib_cdev_register (struct gpio_device *gdev,dev_t devt) { -struct gpio_chip *gc;int ret;cdev_init (&gdev->chrdev, &gpio_fileops);
@@ -2799,7 +2798,7 @@ int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt)if (!rcu_access_pointer (gdev->chip))return -ENODEV ; -chip_dbg (gc,"added GPIO chardev (%d:%d)\n" ,MAJOR (devt), gdev->id); +dev_dbg (&gdev->dev,"added GPIO chardev (%d:%d)\n" ,MAJOR (devt), gdev->id);return 0 ; }
Signature · 1 line
2.39.2
Quoted 12 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The 'gc' variable is never set before it gets printed:
drivers/gpio/gpiolib-cdev.c:2802:11: error: variable 'gc' is uninitialized when used here [-Werror,-Wuninitialized]
2802 |chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id);
| ^~drivers/gpio/gpiolib.h:277:11: note: expanded from macro 'chip_dbg'
277 |dev_dbg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__)
| ^~
Quoted 5 lines
Use
dev_dbg()directly.Fixes 8574b5b47610 ("gpio: cdev: use correct pointer accessors with SRCU")Signed-off-by Arnd Bergmann <[email protected]>---
Hi Arnd,
I seem to have beat you to it[1] and my patch doesn't change the log message so I'll apply it instead of this one.
Thanks,
Bartosz
[1] https://lore.kernel.org/linux-gpio/[email protected]/T/#t
Quoted 13 lines · Bartosz Golaszewski
Quoted 12 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The 'gc' variable is never set before it gets printed:
drivers/gpio/gpiolib-cdev.c:2802:11: error: variable 'gc' is uninitialized when used here [-Werror,-Wuninitialized]
2802 |chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id);
| ^~drivers/gpio/gpiolib.h:277:11: note: expanded from macro 'chip_dbg'
277 |dev_dbg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__)
| ^~
Quoted 8 lines
Quoted 5 lines
Use
dev_dbg()directly.Fixes 8574b5b47610 ("gpio: cdev: use correct pointer accessors with SRCU")Signed-off-by Arnd Bergmann <[email protected]>---
I seem to have beat you to it[1] and my patch doesn't change the log message so I'll apply it instead of this one.
Ok, thanks. I thought about doing this, but could not figure out which of the RCU primitives to use.
Arnd
Quoted 20 lines · Arnd Bergmann
Quoted 19 lines · Bartosz Golaszewski
Quoted 17 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The 'gc' variable is never set before it gets printed:
drivers/gpio/gpiolib-cdev.c:2802:11: error: variable 'gc' is uninitialized when used here [-Werror,-Wuninitialized]
2802 |chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id);
| ^~drivers/gpio/gpiolib.h:277:11: note: expanded from macro 'chip_dbg'
277 |dev_dbg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__)
| ^~Use
dev_dbg()directly.Fixes 8574b5b47610 ("gpio: cdev: use correct pointer accessors with SRCU")Signed-off-by Arnd Bergmann <[email protected]>---
Quoted 5 lines
Quoted 2 lines
I seem to have beat you to it[1] and my patch doesn't change the log message so I'll apply it instead of this one.
Ok, thanks. I thought about doing this, but could not figure out which of the RCU primitives to use.
I will count that as a bug against RCU's documentation, but I am not sure how to fix it. Thoughts?
Thanx, Paul
Quoted 21 lines · Paul E. McKenney
Quoted 20 lines · Arnd Bergmann
Quoted 19 lines · Bartosz Golaszewski
Quoted 17 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The 'gc' variable is never set before it gets printed:
drivers/gpio/gpiolib-cdev.c:2802:11: error: variable 'gc' is uninitialized when used here [-Werror,-Wuninitialized]
2802 |chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id);
| ^~drivers/gpio/gpiolib.h:277:11: note: expanded from macro 'chip_dbg'
277 |dev_dbg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__)
| ^~Use
dev_dbg()directly.Fixes 8574b5b47610 ("gpio: cdev: use correct pointer accessors with SRCU")Signed-off-by Arnd Bergmann <[email protected]>---
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I seem to have beat you to it[1] and my patch doesn't change the log message so I'll apply it instead of this one.
Ok, thanks. I thought about doing this, but could not figure out which of the RCU primitives to use.
I will count that as a bug against RCU's documentation, but I am not sure how to fix it. Thoughts?
I didn't really try at all, I just figured I could avoid thinking about it by using the device pointer at hand.
I'm sure the docs would have told me if I had bothered to look.
Arnd
Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · Paul E. McKenney
Quoted 25 lines · Arnd Bergmann
Quoted 13 lines · Bartosz Golaszewski
Quoted 12 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The 'gc' variable is never set before it gets printed:
drivers/gpio/gpiolib-cdev.c:2802:11: error: variable 'gc' is uninitialized when used here [-Werror,-Wuninitialized]
2802 |chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id);
| ^~drivers/gpio/gpiolib.h:277:11: note: expanded from macro 'chip_dbg'
277 |dev_dbg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__)
| ^~Quoted 8 lines
Quoted 5 lines
Use
dev_dbg()directly.Fixes 8574b5b47610 ("gpio: cdev: use correct pointer accessors with SRCU")Signed-off-by Arnd Bergmann <[email protected]>---
I seem to have beat you to it[1] and my patch doesn't change the log message so I'll apply it instead of this one.
Ok, thanks. I thought about doing this, but could not figure out which of the RCU primitives to use.
Quoted 7 lines
Quoted 2 lines
I will count that as a bug against RCU's documentation, but I am not sure how to fix it. Thoughts?
I didn't really try at all, I just figured I could avoid thinking about it by using the device pointer at hand.
I'm sure the docs would have told me if I had bothered to look.
OK, a low-priority bug against RCU's documentation, then. ;-)
Thanx, paul