gpio fixes for v5.11-rc7

- fix a memory leak in error path in gpiolib
 - clear debounce period in output mode in the character device code
 - remove shadowed variable
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmAanr4ACgkQEacuoBRx
 13IfxA//deFRpmCfLKaIziXo2Ta5lrTWN2lwQZtb/vxhOUe9gEdtRSoGb1ftsCx+
 S6NVX7InP39hpLLZZCNFrqIVKUi6M5uIw8HlYgJQnbkDh6Mgi8mcQuYsDQt9SZDu
 nps1d88FruMB/EfmR53M0UBQx6RXyt2yUdbcuvg+3mH65a/ZdRJSyrEqs2sA2pKk
 xDT5fCcPiF7EngzGpNbTR1l6SrlGOudpy38H89cS00SmMKFau5vVvq4+87InbfEc
 uqiaePehwg+Vt4gjvag58CyHHfoQhelSWN+IgyD+BJOARLslqra5hc7/zeytXGgE
 mZhItDtgWFR2+XPA4vSGyH4jBP7sRj9gQPkviX4+XODBCvoLIlvMCbsMeDTsIFBC
 LCjwrAEjcd080+YepdbHaafCSb1uMF2oHMI19XThRNsVahLXhs0tymfXi3VvjvQj
 wUFkMBx1uvobYRjIGfF21490fXFBri9mXeZR4BWsrkdY2hLNiOftUolE/UEEqOU6
 x3d9ZUtRBiVltES6UC1jNQTIDLcnKM31Iqc2Vg8xInsjQ0XLQtdp9BMXn8yHf2mx
 kIgbVjF9MMHwHTdcXuFCI4t6h6fqxrIz0yi2Y44FAHU0odEkuBv9cdLRUzTvo14b
 nz51ay1jSn9W/rTMAyTX24RevWE8DVAGLk0Yg9SPRMLnQ3faZhQ=
 =gNKm
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2021-02-03 09:44:22 -08:00
commit 40615974f8
2 changed files with 11 additions and 3 deletions

View File

@ -776,6 +776,8 @@ static void edge_detector_stop(struct line *line)
cancel_delayed_work_sync(&line->work);
WRITE_ONCE(line->sw_debounced, 0);
WRITE_ONCE(line->eflags, 0);
if (line->desc)
WRITE_ONCE(line->desc->debounce_period_us, 0);
/* do not change line->level - see comment in debounced_value() */
}

View File

@ -603,7 +603,11 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
ret = gdev->id;
goto err_free_gdev;
}
dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);
ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);
if (ret)
goto err_free_ida;
device_initialize(&gdev->dev);
dev_set_drvdata(&gdev->dev, gdev);
if (gc->parent && gc->parent->driver)
@ -617,7 +621,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
gdev->descs = kcalloc(gc->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL);
if (!gdev->descs) {
ret = -ENOMEM;
goto err_free_ida;
goto err_free_dev_name;
}
if (gc->ngpio == 0) {
@ -768,6 +772,8 @@ err_free_label:
kfree_const(gdev->label);
err_free_descs:
kfree(gdev->descs);
err_free_dev_name:
kfree(dev_name(&gdev->dev));
err_free_ida:
ida_free(&gpio_ida, gdev->id);
err_free_gdev:
@ -2551,7 +2557,7 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
struct gpio_chip *gc = desc_array[i]->gdev->chip;
unsigned long fastpath[2 * BITS_TO_LONGS(FASTPATH_NGPIO)];
unsigned long *mask, *bits;
int first, j, ret;
int first, j;
if (likely(gc->ngpio <= FASTPATH_NGPIO)) {
mask = fastpath;