* [PATCH v3 1/7] nvmem: fix memory leak in error path
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
@ 2020-02-19 9:22 ` Bartosz Golaszewski
2020-02-19 10:52 ` Srinivas Kandagatla
2020-02-19 9:22 ` [PATCH v3 2/7] gpiolib: use kref in gpio_desc Bartosz Golaszewski
` (6 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 9:22 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>
We need to free the ida mapping and nvmem struct if the write-protect
GPIO lookup fails.
Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index ef326f243f36..89974e40d250 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -352,8 +352,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
else
nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
GPIOD_OUT_HIGH);
- if (IS_ERR(nvmem->wp_gpio))
- return ERR_CAST(nvmem->wp_gpio);
+ if (IS_ERR(nvmem->wp_gpio)) {
+ ida_simple_remove(&nvmem_ida, nvmem->id);
+ kfree(nvmem);
+ return ERR_PTR(rval);
+ }
kref_init(&nvmem->refcnt);
--
2.25.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 1/7] nvmem: fix memory leak in error path
2020-02-19 9:22 ` [PATCH v3 1/7] nvmem: fix memory leak in error path Bartosz Golaszewski
@ 2020-02-19 10:52 ` Srinivas Kandagatla
2020-02-19 10:53 ` Bartosz Golaszewski
0 siblings, 1 reply; 13+ messages in thread
From: Srinivas Kandagatla @ 2020-02-19 10:52 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Khouloud Touil,
Geert Uytterhoeven
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
On 19/02/2020 09:22, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski<bgolaszewski@baylibre.com>
>
> We need to free the ida mapping and nvmem struct if the write-protect
> GPIO lookup fails.
>
> Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
> Signed-off-by: Bartosz Golaszewski<bgolaszewski@baylibre.com>
> ---
> drivers/nvmem/core.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index ef326f243f36..89974e40d250 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -352,8 +352,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> else
> nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
> GPIOD_OUT_HIGH);
> - if (IS_ERR(nvmem->wp_gpio))
> - return ERR_CAST(nvmem->wp_gpio);
> + if (IS_ERR(nvmem->wp_gpio)) {
> + ida_simple_remove(&nvmem_ida, nvmem->id);
> + kfree(nvmem);
> + return ERR_PTR(rval);
Why are you returning rval here?
This points return value of ida_simple_get and not the actual error code
from wp_gpio.
--srini
> + }
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v3 1/7] nvmem: fix memory leak in error path
2020-02-19 10:52 ` Srinivas Kandagatla
@ 2020-02-19 10:53 ` Bartosz Golaszewski
0 siblings, 0 replies; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 10:53 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Bartosz Golaszewski, Linus Walleij, Khouloud Touil,
Geert Uytterhoeven, linux-gpio, LKML
śr., 19 lut 2020 o 11:52 Srinivas Kandagatla
<srinivas.kandagatla@linaro.org> napisał(a):
>
>
>
> On 19/02/2020 09:22, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski<bgolaszewski@baylibre.com>
> >
> > We need to free the ida mapping and nvmem struct if the write-protect
> > GPIO lookup fails.
> >
> > Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
> > Signed-off-by: Bartosz Golaszewski<bgolaszewski@baylibre.com>
> > ---
> > drivers/nvmem/core.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> > index ef326f243f36..89974e40d250 100644
> > --- a/drivers/nvmem/core.c
> > +++ b/drivers/nvmem/core.c
> > @@ -352,8 +352,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> > else
> > nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
> > GPIOD_OUT_HIGH);
> > - if (IS_ERR(nvmem->wp_gpio))
> > - return ERR_CAST(nvmem->wp_gpio);
> > + if (IS_ERR(nvmem->wp_gpio)) {
> > + ida_simple_remove(&nvmem_ida, nvmem->id);
> > + kfree(nvmem);
> > + return ERR_PTR(rval);
>
> Why are you returning rval here?
> This points return value of ida_simple_get and not the actual error code
> from wp_gpio.
>
Duh! Thanks for catching this.
Bart
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 2/7] gpiolib: use kref in gpio_desc
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
2020-02-19 9:22 ` [PATCH v3 1/7] nvmem: fix memory leak in error path Bartosz Golaszewski
@ 2020-02-19 9:22 ` Bartosz Golaszewski
2020-02-21 13:40 ` Linus Walleij
2020-02-19 9:22 ` [PATCH v3 3/7] nvmem: increase the reference count of a gpio passed over config Bartosz Golaszewski
` (5 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 9:22 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>
GPIO descriptors are freed by consumers using gpiod_put(). The name of
this function suggests some reference counting is going on but it's not
true.
Use kref to actually introduce reference counting for gpio_desc objects.
Add a corresponding gpiod_get() helper for increasing the reference count.
This doesn't change anything for already existing (correct) drivers but
allows us to keep track of GPIO descs used by multiple users.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/gpio/gpiolib.c | 36 ++++++++++++++++++++++++++++++++---
drivers/gpio/gpiolib.h | 1 +
include/linux/gpio/consumer.h | 1 +
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4d0106ceeba7..78220e86b2bd 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2798,6 +2798,8 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
goto done;
}
+ kref_init(&desc->ref);
+
if (chip->request) {
/* chip->request may sleep */
spin_unlock_irqrestore(&gpio_lock, flags);
@@ -2933,6 +2935,13 @@ void gpiod_free(struct gpio_desc *desc)
}
}
+static void gpiod_free_kref(struct kref *ref)
+{
+ struct gpio_desc *desc = container_of(ref, struct gpio_desc, ref);
+
+ gpiod_free(desc);
+}
+
/**
* gpiochip_is_requested - return string iff signal was requested
* @chip: controller managing the signal
@@ -5067,18 +5076,39 @@ struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev,
EXPORT_SYMBOL_GPL(gpiod_get_array_optional);
/**
- * gpiod_put - dispose of a GPIO descriptor
- * @desc: GPIO descriptor to dispose of
+ * gpiod_put - decrease the reference count of a GPIO descriptor
+ * @desc: GPIO descriptor to unref
*
* No descriptor can be used after gpiod_put() has been called on it.
*/
void gpiod_put(struct gpio_desc *desc)
{
if (desc)
- gpiod_free(desc);
+ kref_put(&desc->ref, gpiod_free_kref);
}
EXPORT_SYMBOL_GPL(gpiod_put);
+/**
+ * gpiod_ref - increase the reference count of a GPIO descriptor
+ * @desc: GPIO descriptor to reference
+ *
+ * Returns the same gpio_desc after increasing the reference count.
+ */
+struct gpio_desc *gpiod_ref(struct gpio_desc *desc)
+{
+ if (!desc)
+ return NULL;
+
+ if (!test_bit(FLAG_REQUESTED, &desc->flags)) {
+ pr_warn("gpiolib: unable to increase the reference count of unrequested GPIO descriptor\n");
+ return desc;
+ }
+
+ kref_get(&desc->ref);
+ return desc;
+}
+EXPORT_SYMBOL_GPL(gpiod_ref);
+
/**
* gpiod_put_array - dispose of multiple GPIO descriptors
* @descs: struct gpio_descs containing an array of descriptors
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 3e0aab2945d8..51a92c43dd55 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -119,6 +119,7 @@ struct gpio_desc {
const char *label;
/* Name of the GPIO */
const char *name;
+ struct kref ref;
};
int gpiod_request(struct gpio_desc *desc, const char *label);
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index bf2d017dd7b7..c7b5fb3d9d64 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -81,6 +81,7 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev,
struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev,
const char *con_id,
enum gpiod_flags flags);
+struct gpio_desc *gpiod_ref(struct gpio_desc *desc);
void gpiod_put(struct gpio_desc *desc);
void gpiod_put_array(struct gpio_descs *descs);
--
2.25.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 2/7] gpiolib: use kref in gpio_desc
2020-02-19 9:22 ` [PATCH v3 2/7] gpiolib: use kref in gpio_desc Bartosz Golaszewski
@ 2020-02-21 13:40 ` Linus Walleij
0 siblings, 0 replies; 13+ messages in thread
From: Linus Walleij @ 2020-02-21 13:40 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Srinivas Kandagatla, Khouloud Touil, Geert Uytterhoeven,
open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org,
Bartosz Golaszewski
On Wed, Feb 19, 2020 at 10:22 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> GPIO descriptors are freed by consumers using gpiod_put(). The name of
> this function suggests some reference counting is going on but it's not
> true.
>
> Use kref to actually introduce reference counting for gpio_desc objects.
> Add a corresponding gpiod_get() helper for increasing the reference count.
>
> This doesn't change anything for already existing (correct) drivers but
> allows us to keep track of GPIO descs used by multiple users.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
I really like the simplicity of this approach ... hm!
It seems the only downside is a krefcount_t extra per gpio_desc
which is an atomic_t so I guess 32 or 64 bits per desc depending
on arch.
We discussed refcounts in gpiods in another context but it got
really complicated there. This is a clearly cut usecase.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 3/7] nvmem: increase the reference count of a gpio passed over config
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
2020-02-19 9:22 ` [PATCH v3 1/7] nvmem: fix memory leak in error path Bartosz Golaszewski
2020-02-19 9:22 ` [PATCH v3 2/7] gpiolib: use kref in gpio_desc Bartosz Golaszewski
@ 2020-02-19 9:22 ` Bartosz Golaszewski
2020-02-19 9:22 ` [PATCH v3 4/7] nvmem: release the write-protect pin Bartosz Golaszewski
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 9:22 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>
We can obtain the write-protect GPIO in nvmem_register() by requesting
it ourselves or by storing the gpio_desc passed in nvmem_config. In the
latter case we need to increase the reference count so that it gets
freed correctly.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 89974e40d250..4e6daaa2b0f6 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -348,7 +348,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
return ERR_PTR(rval);
}
if (config->wp_gpio)
- nvmem->wp_gpio = config->wp_gpio;
+ nvmem->wp_gpio = gpiod_ref(config->wp_gpio);
else
nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
GPIOD_OUT_HIGH);
--
2.25.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 4/7] nvmem: release the write-protect pin
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
` (2 preceding siblings ...)
2020-02-19 9:22 ` [PATCH v3 3/7] nvmem: increase the reference count of a gpio passed over config Bartosz Golaszewski
@ 2020-02-19 9:22 ` Bartosz Golaszewski
2020-02-19 9:22 ` [PATCH v3 5/7] nvmem: remove a stray newline in nvmem_register() Bartosz Golaszewski
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 9:22 UTC (permalink / raw)
To: Linus Walleij, Srinivas Kandagatla, Khouloud Touil,
Geert Uytterhoeven
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
From: Khouloud Touil <ktouil@baylibre.com>
Put the write-protect GPIO descriptor in nvmem_release() so that it can
be automatically released when the associated device's reference count
drops to 0.
Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Khouloud Touil <ktouil@baylibre.com>
[Bartosz: tweak the commit message]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 4e6daaa2b0f6..c718ed7859e8 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -72,6 +72,7 @@ static void nvmem_release(struct device *dev)
struct nvmem_device *nvmem = to_nvmem_device(dev);
ida_simple_remove(&nvmem_ida, nvmem->id);
+ gpiod_put(nvmem->wp_gpio);
kfree(nvmem);
}
--
2.25.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 5/7] nvmem: remove a stray newline in nvmem_register()
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
` (3 preceding siblings ...)
2020-02-19 9:22 ` [PATCH v3 4/7] nvmem: release the write-protect pin Bartosz Golaszewski
@ 2020-02-19 9:22 ` Bartosz Golaszewski
2020-02-19 9:22 ` [PATCH v3 6/7] nvmem: add a newline for readability Bartosz Golaszewski
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 9:22 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>
Two newlines are unnecessary - remove one.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index c718ed7859e8..bbdf2fe076b9 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -359,7 +359,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
return ERR_PTR(rval);
}
-
kref_init(&nvmem->refcnt);
INIT_LIST_HEAD(&nvmem->cells);
--
2.25.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 6/7] nvmem: add a newline for readability
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
` (4 preceding siblings ...)
2020-02-19 9:22 ` [PATCH v3 5/7] nvmem: remove a stray newline in nvmem_register() Bartosz Golaszewski
@ 2020-02-19 9:22 ` Bartosz Golaszewski
2020-02-19 9:22 ` [PATCH v3 7/7] nvmem: add a comment about resource management Bartosz Golaszewski
2020-02-19 11:00 ` [PATCH v3 0/7] nvmem/gpio: fix " Srinivas Kandagatla
7 siblings, 0 replies; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 9:22 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>
Visibly separate the GPIO request from the previous operation in the
code with a newline.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index bbdf2fe076b9..40fe5913c264 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -348,6 +348,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
kfree(nvmem);
return ERR_PTR(rval);
}
+
if (config->wp_gpio)
nvmem->wp_gpio = gpiod_ref(config->wp_gpio);
else
--
2.25.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 7/7] nvmem: add a comment about resource management
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
` (5 preceding siblings ...)
2020-02-19 9:22 ` [PATCH v3 6/7] nvmem: add a newline for readability Bartosz Golaszewski
@ 2020-02-19 9:22 ` Bartosz Golaszewski
2020-02-19 10:57 ` Srinivas Kandagatla
2020-02-19 11:00 ` [PATCH v3 0/7] nvmem/gpio: fix " Srinivas Kandagatla
7 siblings, 1 reply; 13+ messages in thread
From: Bartosz Golaszewski @ 2020-02-19 9:22 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>
The fact that part of the resources associated with the nvmem resources
is freed by the release() callback in device_type caused me some
confusion. Add a comment explaining that to nvmem_register().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 40fe5913c264..6e28f3fddf53 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -397,6 +397,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
+ /*
+ * After calling device_add() we can stop freeing previously
+ * allocated resources - they'll be freed from nvmem_release()
+ * when the device's reference count drops to 0.
+ */
rval = device_add(&nvmem->dev);
if (rval)
goto err_put_device;
--
2.25.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 7/7] nvmem: add a comment about resource management
2020-02-19 9:22 ` [PATCH v3 7/7] nvmem: add a comment about resource management Bartosz Golaszewski
@ 2020-02-19 10:57 ` Srinivas Kandagatla
0 siblings, 0 replies; 13+ messages in thread
From: Srinivas Kandagatla @ 2020-02-19 10:57 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Khouloud Touil,
Geert Uytterhoeven
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
On 19/02/2020 09:22, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> The fact that part of the resources associated with the nvmem resources
> is freed by the release() callback in device_type caused me some
> confusion. Add a comment explaining that to nvmem_register().
I see this patch totally unnecessary!
I expect people creating patch in this area to understand what exactly
they are doing. This is not going to help them in anyway, other than
misleading and re-documenting device_add which is already available at
https://www.kernel.org/doc/html/v5.5/driver-api/infrastructure.html
thanks,
srini
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
> drivers/nvmem/core.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 40fe5913c264..6e28f3fddf53 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -397,6 +397,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
>
> dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
>
> + /*
> + * After calling device_add() we can stop freeing previously
> + * allocated resources - they'll be freed from nvmem_release()
> + * when the device's reference count drops to 0.
> + */
> rval = device_add(&nvmem->dev);
> if (rval)
> goto err_put_device;
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 0/7] nvmem/gpio: fix resource management
2020-02-19 9:22 [PATCH v3 0/7] nvmem/gpio: fix resource management Bartosz Golaszewski
` (6 preceding siblings ...)
2020-02-19 9:22 ` [PATCH v3 7/7] nvmem: add a comment about resource management Bartosz Golaszewski
@ 2020-02-19 11:00 ` Srinivas Kandagatla
7 siblings, 0 replies; 13+ messages in thread
From: Srinivas Kandagatla @ 2020-02-19 11:00 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Khouloud Touil,
Geert Uytterhoeven
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
On 19/02/2020 09:22, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
Can you please rebase your patches on top of
https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git/log/?h=for-next
--srini
^ permalink raw reply [flat|nested] 13+ messages in thread