All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver: regmap: set debugfs_name to NULL after it is freed
@ 2021-02-26  2:17 Meng.Li
  2021-03-09 19:07 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Meng.Li @ 2021-02-26  2:17 UTC (permalink / raw)
  To: linux-kernel, broonie, gregkh, rafael; +Cc: meng.li

From: Meng Li <Meng.Li@windriver.com>

There is a upstream commit cffa4b2122f5("regmap:debugfs:
Fix a memory leak when calling regmap_attach_dev") that
adds a if condition when create name for debugfs_name.
With below function invoking logical, debugfs_name is
freed in regmap_debugfs_exit(), but it is not created again
because of the if condition introduced by above commit.
regmap_reinit_cache()
	regmap_debugfs_exit()
	...
	regmap_debugfs_init()
So, set debugfs_name to NULL after it is freed.

Fixes: cffa4b2122f5("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev")
Cc: stable@vger.kernel.org
Signed-off-by: Meng Li <Meng.Li@windriver.com>
---
 drivers/base/regmap/regmap-debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 398991381e9a..4f2ff1b2b450 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -661,6 +661,7 @@ void regmap_debugfs_exit(struct regmap *map)
 		regmap_debugfs_free_dump_cache(map);
 		mutex_unlock(&map->cache_lock);
 		kfree(map->debugfs_name);
+		map->debugfs_name = NULL;
 	} else {
 		struct regmap_debugfs_node *node, *tmp;
 
-- 
2.17.1


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

* Re: [PATCH] driver: regmap: set debugfs_name to NULL after it is freed
  2021-02-26  2:17 [PATCH] driver: regmap: set debugfs_name to NULL after it is freed Meng.Li
@ 2021-03-09 19:07 ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2021-03-09 19:07 UTC (permalink / raw)
  To: linux-kernel, Meng.Li, gregkh, rafael; +Cc: meng.li

On Fri, 26 Feb 2021 10:17:37 +0800, Meng.Li@windriver.com wrote:
> There is a upstream commit cffa4b2122f5("regmap:debugfs:
> Fix a memory leak when calling regmap_attach_dev") that
> adds a if condition when create name for debugfs_name.
> With below function invoking logical, debugfs_name is
> freed in regmap_debugfs_exit(), but it is not created again
> because of the if condition introduced by above commit.
> regmap_reinit_cache()
> 	regmap_debugfs_exit()
> 	...
> 	regmap_debugfs_init()
> So, set debugfs_name to NULL after it is freed.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] driver: regmap: set debugfs_name to NULL after it is freed
      commit: ffe96a97642021e96ff27b29710401590ec19a5d

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

* RE: [PATCH] driver: regmap: set debugfs_name to NULL after it is freed
  2021-02-26  2:15 Meng.Li
@ 2021-02-26  2:19 ` Li, Meng
  0 siblings, 0 replies; 4+ messages in thread
From: Li, Meng @ 2021-02-26  2:19 UTC (permalink / raw)
  To: linux-kernel, broonie, rafael

Please discard this email. There is a wrong email address in TO list.
I have sent another one.

Thanks,
Limeng

> -----Original Message-----
> From: Li, Meng <Meng.Li@windriver.com>
> Sent: Friday, February 26, 2021 10:16 AM
> To: linux-kernel@vger.kernel.org; broonie@kernel.org;
> regkh@linuxfoundation.org; rafael@kernel.org
> Cc: Li, Meng <Meng.Li@windriver.com>
> Subject: [PATCH] driver: regmap: set debugfs_name to NULL after it is freed
> 
> From: Meng Li <Meng.Li@windriver.com>
> 
> There is a upstream commit cffa4b2122f5("regmap:debugfs:
> Fix a memory leak when calling regmap_attach_dev") that adds a if condition
> when create name for debugfs_name.
> With below function invoking logical, debugfs_name is freed in
> regmap_debugfs_exit(), but it is not created again because of the if
> condition introduced by above commit.
> regmap_reinit_cache()
> 	regmap_debugfs_exit()
> 	...
> 	regmap_debugfs_init()
> So, set debugfs_name to NULL after it is freed.
> 
> Fixes: cffa4b2122f5("regmap: debugfs: Fix a memory leak when calling
> regmap_attach_dev")
> Cc: stable@vger.kernel.org
> Signed-off-by: Meng Li <Meng.Li@windriver.com>
> ---
>  drivers/base/regmap/regmap-debugfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/base/regmap/regmap-debugfs.c
> b/drivers/base/regmap/regmap-debugfs.c
> index 398991381e9a..4f2ff1b2b450 100644
> --- a/drivers/base/regmap/regmap-debugfs.c
> +++ b/drivers/base/regmap/regmap-debugfs.c
> @@ -661,6 +661,7 @@ void regmap_debugfs_exit(struct regmap *map)
>  		regmap_debugfs_free_dump_cache(map);
>  		mutex_unlock(&map->cache_lock);
>  		kfree(map->debugfs_name);
> +		map->debugfs_name = NULL;
>  	} else {
>  		struct regmap_debugfs_node *node, *tmp;
> 
> --
> 2.17.1


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

* [PATCH] driver: regmap: set debugfs_name to NULL after it is freed
@ 2021-02-26  2:15 Meng.Li
  2021-02-26  2:19 ` Li, Meng
  0 siblings, 1 reply; 4+ messages in thread
From: Meng.Li @ 2021-02-26  2:15 UTC (permalink / raw)
  To: linux-kernel, broonie, regkh, rafael; +Cc: meng.li

From: Meng Li <Meng.Li@windriver.com>

There is a upstream commit cffa4b2122f5("regmap:debugfs:
Fix a memory leak when calling regmap_attach_dev") that
adds a if condition when create name for debugfs_name.
With below function invoking logical, debugfs_name is
freed in regmap_debugfs_exit(), but it is not created again
because of the if condition introduced by above commit.
regmap_reinit_cache()
	regmap_debugfs_exit()
	...
	regmap_debugfs_init()
So, set debugfs_name to NULL after it is freed.

Fixes: cffa4b2122f5("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev")
Cc: stable@vger.kernel.org
Signed-off-by: Meng Li <Meng.Li@windriver.com>
---
 drivers/base/regmap/regmap-debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 398991381e9a..4f2ff1b2b450 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -661,6 +661,7 @@ void regmap_debugfs_exit(struct regmap *map)
 		regmap_debugfs_free_dump_cache(map);
 		mutex_unlock(&map->cache_lock);
 		kfree(map->debugfs_name);
+		map->debugfs_name = NULL;
 	} else {
 		struct regmap_debugfs_node *node, *tmp;
 
-- 
2.17.1


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

end of thread, other threads:[~2021-03-09 19:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26  2:17 [PATCH] driver: regmap: set debugfs_name to NULL after it is freed Meng.Li
2021-03-09 19:07 ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2021-02-26  2:15 Meng.Li
2021-02-26  2:19 ` Li, Meng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.