linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/5] nvmem/gpio: fix resource management
@ 2020-02-21 15:48 Bartosz Golaszewski
  2020-02-21 15:48 ` [PATCH v5 1/5] nvmem: fix memory leak in error path Bartosz Golaszewski
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2020-02-21 15:48 UTC (permalink / raw)
  To: Linus Walleij, Srinivas Kandagatla, Khouloud Touil, Geert Uytterhoeven
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Hi Srinivas,

sorry for the lack of proper QA last time. This time the code is tested
on real HW (Beagle Bone Black with an ACME cape) including the error
path.

--

This series addresses a couple problems with memory management in nvmem
core.

First we fix a memory leak introduced in this release cycle. Next we extend
the GPIO framework to use reference counting for GPIO descriptors. We then
use it to fix the resource management problem with the write-protect pin.

While the memory leak with wp-gpios is now in mainline - I'm not sure how
to go about applying the kref patch. This is theoretically a new feature
but it's also the cleanest way of fixing the problem.

v1 -> v2:
- make gpiod_ref() helper return
- reorganize the series for easier merging
- fix another memory leak

v2 -> v3:
- drop incorrect patches
- add a patch adding a comment about resource management
- extend the GPIO kref patch: only increment the reference count if the
  descriptor is associated with a requested line

v3 -> v4:
- fixed the return value in error path in nvmem_register()
- dropped patches already applied to the nvmem tree
- dropped the patch adding the comment about resource management

v4 -> v5:
- don't reference nvmem once it's freed
- add GPIO descriptor validation in gpiod_ref()

Bartosz Golaszewski (4):
  nvmem: fix memory leak in error path
  gpiolib: provide VALIDATE_DESC_PTR() macro
  gpiolib: use kref in gpio_desc
  nvmem: increase the reference count of a gpio passed over config

Khouloud Touil (1):
  nvmem: release the write-protect pin

 drivers/gpio/gpiolib.c        | 46 ++++++++++++++++++++++++++++++++---
 drivers/gpio/gpiolib.h        |  1 +
 drivers/nvmem/core.c          | 11 ++++++---
 include/linux/gpio/consumer.h |  1 +
 4 files changed, 52 insertions(+), 7 deletions(-)

-- 
2.25.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-02-29 20:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 15:48 [PATCH v5 0/5] nvmem/gpio: fix resource management Bartosz Golaszewski
2020-02-21 15:48 ` [PATCH v5 1/5] nvmem: fix memory leak in error path Bartosz Golaszewski
2020-02-21 16:42   ` Srinivas Kandagatla
2020-02-21 15:48 ` [PATCH v5 2/5] gpiolib: provide VALIDATE_DESC_PTR() macro Bartosz Golaszewski
2020-02-28 22:15   ` Linus Walleij
2020-02-21 15:48 ` [PATCH v5 3/5] gpiolib: use kref in gpio_desc Bartosz Golaszewski
2020-02-28 22:32   ` Linus Walleij
2020-02-29 20:15     ` Bartosz Golaszewski
2020-02-21 15:48 ` [PATCH v5 4/5] nvmem: increase the reference count of a gpio passed over config Bartosz Golaszewski
2020-02-21 15:48 ` [PATCH v5 5/5] nvmem: release the write-protect pin 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).