Skip to content

Commit 4061597

Browse files
committed
Merge tag 'gpio-fixes-for-v5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: "Some more fixes from the GPIO subsystem for this release. This time it's only core fixes: - fix a memory leak in error path in gpiolib - clear debounce period in output mode in the character device code - remove shadowed variable" * tag 'gpio-fixes-for-v5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: gpiolib: remove shadowed variable gpiolib: free device name on error path to fix kmemleak gpiolib: cdev: clear debounce period if line set to output
2 parents 4aa2fb4 + c07ea8d commit 4061597

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

drivers/gpio/gpiolib-cdev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ static void edge_detector_stop(struct line *line)
776776
cancel_delayed_work_sync(&line->work);
777777
WRITE_ONCE(line->sw_debounced, 0);
778778
WRITE_ONCE(line->eflags, 0);
779+
if (line->desc)
780+
WRITE_ONCE(line->desc->debounce_period_us, 0);
779781
/* do not change line->level - see comment in debounced_value() */
780782
}
781783

drivers/gpio/gpiolib.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,11 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
603603
ret = gdev->id;
604604
goto err_free_gdev;
605605
}
606-
dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);
606+
607+
ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);
608+
if (ret)
609+
goto err_free_ida;
610+
607611
device_initialize(&gdev->dev);
608612
dev_set_drvdata(&gdev->dev, gdev);
609613
if (gc->parent && gc->parent->driver)
@@ -617,7 +621,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
617621
gdev->descs = kcalloc(gc->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL);
618622
if (!gdev->descs) {
619623
ret = -ENOMEM;
620-
goto err_free_ida;
624+
goto err_free_dev_name;
621625
}
622626

623627
if (gc->ngpio == 0) {
@@ -768,6 +772,8 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
768772
kfree_const(gdev->label);
769773
err_free_descs:
770774
kfree(gdev->descs);
775+
err_free_dev_name:
776+
kfree(dev_name(&gdev->dev));
771777
err_free_ida:
772778
ida_free(&gpio_ida, gdev->id);
773779
err_free_gdev:
@@ -2551,7 +2557,7 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
25512557
struct gpio_chip *gc = desc_array[i]->gdev->chip;
25522558
unsigned long fastpath[2 * BITS_TO_LONGS(FASTPATH_NGPIO)];
25532559
unsigned long *mask, *bits;
2554-
int first, j, ret;
2560+
int first, j;
25552561

25562562
if (likely(gc->ngpio <= FASTPATH_NGPIO)) {
25572563
mask = fastpath;

0 commit comments

Comments
 (0)