Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
* [PATCH 0/2] mfd: Remove LP873x and TPS65218 child devices on teardown
@ 2026-11-26 13:28 Tian Xuechen
  2026-11-26 13:28 ` [PATCH 1/2] mfd: lp873x: Remove the child devices on unbind Tian Xuechen
  2026-11-26 13:28 ` [PATCH 2/2] mfd: tps65218: Fix potential use-after-free by child devices Tian Xuechen
  0 siblings, 2 replies; 5+ messages in thread
From: Tian Xuechen @ 2026-11-26 13:28 UTC (permalink / raw)
  To: lee, aaro.koskinen, andreas, khilman, rogerq, tony, j-keerthy
  Cc: mfd, linux-omap, liguangshuo

From: Tian Xuechen <202300460064@mail.sdu.edu.cn>

Pair child device registration with removal in the LP873x and TPS65218
drivers.

Tian Xuechen (2):
  mfd: lp873x: Remove the child devices on unbind
  mfd: tps65218: Fix potential use-after-free by child devices

base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5

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

* [PATCH 1/2] mfd: lp873x: Remove the child devices on unbind
  2026-11-26 13:28 [PATCH 0/2] mfd: Remove LP873x and TPS65218 child devices on teardown Tian Xuechen
@ 2026-11-26 13:28 ` Tian Xuechen
  2026-12-02 16:26   ` Lee Jones
  2026-11-26 13:28 ` [PATCH 2/2] mfd: tps65218: Fix potential use-after-free by child devices Tian Xuechen
  1 sibling, 1 reply; 5+ messages in thread
From: Tian Xuechen @ 2026-11-26 13:28 UTC (permalink / raw)
  To: lee, aaro.koskinen, andreas, khilman, rogerq, tony, j-keerthy
  Cc: mfd, linux-omap, liguangshuo

From: Tian Xuechen <202300460064@mail.sdu.edu.cn>

The regulator and GPIO children stay registered when the I2C driver
is unbound, although they use the parent's managed data. Use managed
MFD registration so the children are removed first.

This issue was found by our static analysis tool under development.

Fixes: dc21c7ad3a8a ("mfd: lp873x: Add lp873x PMIC support")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/mfd/lp873x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
index ab7bd46d9ff7..6b2badab4f2d 100644
--- a/drivers/mfd/lp873x.c
+++ b/drivers/mfd/lp873x.c
@@ -53,8 +53,8 @@ static int lp873x_probe(struct i2c_client *client)
 
 	i2c_set_clientdata(client, lp873);
 
-	ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
-			      ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
+	ret = devm_mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
+				   ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
 
 	return ret;
 }

-- 
2.43.0


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

* [PATCH 2/2] mfd: tps65218: Fix potential use-after-free by child devices
  2026-11-26 13:28 [PATCH 0/2] mfd: Remove LP873x and TPS65218 child devices on teardown Tian Xuechen
  2026-11-26 13:28 ` [PATCH 1/2] mfd: lp873x: Remove the child devices on unbind Tian Xuechen
@ 2026-11-26 13:28 ` Tian Xuechen
  2026-12-02 16:26   ` Lee Jones
  1 sibling, 1 reply; 5+ messages in thread
From: Tian Xuechen @ 2026-11-26 13:28 UTC (permalink / raw)
  To: lee, aaro.koskinen, andreas, khilman, rogerq, tony, j-keerthy
  Cc: mfd, linux-omap, liguangshuo

From: Tian Xuechen <202300460064@mail.sdu.edu.cn>

The MFD children are not removed on unbind, although the parent context
and IRQ chip are device-managed. The children can retain access to
released resources.

Use managed MFD registration to remove the children before the IRQ chip
and parent context are released.

This issue was found by our static analysis tool under development.

Fixes: 44b4dc616365 ("mfd: tps65218: Add driver for the TPS65218 PMIC")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/mfd/tps65218.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c
index 491c379a1a0f..12bef7a11471 100644
--- a/drivers/mfd/tps65218.c
+++ b/drivers/mfd/tps65218.c
@@ -328,9 +328,9 @@ static int tps65218_probe(struct i2c_client *client)
 	if (ret)
 		return ret;
 
-	ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells,
-			      ARRAY_SIZE(tps65218_cells), NULL, 0,
-			      regmap_irq_get_domain(tps->irq_data));
+	ret = devm_mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells,
+				   ARRAY_SIZE(tps65218_cells), NULL, 0,
+				   regmap_irq_get_domain(tps->irq_data));
 
 	return ret;
 }

-- 
2.43.0

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

* Re: [PATCH 2/2] mfd: tps65218: Fix potential use-after-free by child devices
  2026-11-26 13:28 ` [PATCH 2/2] mfd: tps65218: Fix potential use-after-free by child devices Tian Xuechen
@ 2026-12-02 16:26   ` Lee Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-12-02 16:26 UTC (permalink / raw)
  To: Tian Xuechen
  Cc: aaro.koskinen, andreas, khilman, rogerq, tony, j-keerthy, mfd,
	linux-omap, liguangshuo

On Thu, 26 Nov 2026, Tian Xuechen wrote:

> From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> 
> The MFD children are not removed on unbind, although the parent context
> and IRQ chip are device-managed. The children can retain access to
> released resources.
> 
> Use managed MFD registration to remove the children before the IRQ chip
> and parent context are released.
> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: 44b4dc616365 ("mfd: tps65218: Add driver for the TPS65218 PMIC")

This is not correct.  It should be:

4531156db726 ("mfd: tps65218: Use mfd_add_devices instead of of_platform_populate")

> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---
>  drivers/mfd/tps65218.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c
> index 491c379a1a0f..12bef7a11471 100644
> --- a/drivers/mfd/tps65218.c
> +++ b/drivers/mfd/tps65218.c
> @@ -328,9 +328,9 @@ static int tps65218_probe(struct i2c_client *client)
>  	if (ret)
>  		return ret;
>  
> -	ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells,
> -			      ARRAY_SIZE(tps65218_cells), NULL, 0,
> -			      regmap_irq_get_domain(tps->irq_data));
> +	ret = devm_mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells,
> +				   ARRAY_SIZE(tps65218_cells), NULL, 0,
> +				   regmap_irq_get_domain(tps->irq_data));
>  
>  	return ret;

Why not return directly whilst you're at it?

-- 
Lee Jones

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

* Re: [PATCH 1/2] mfd: lp873x: Remove the child devices on unbind
  2026-11-26 13:28 ` [PATCH 1/2] mfd: lp873x: Remove the child devices on unbind Tian Xuechen
@ 2026-12-02 16:26   ` Lee Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-12-02 16:26 UTC (permalink / raw)
  To: Tian Xuechen
  Cc: aaro.koskinen, andreas, khilman, rogerq, tony, j-keerthy, mfd,
	linux-omap, liguangshuo

On Thu, 26 Nov 2026, Tian Xuechen wrote:

> From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> 
> The regulator and GPIO children stay registered when the I2C driver
> is unbound, although they use the parent's managed data. Use managed
> MFD registration so the children are removed first.
> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: dc21c7ad3a8a ("mfd: lp873x: Add lp873x PMIC support")
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---
>  drivers/mfd/lp873x.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
> index ab7bd46d9ff7..6b2badab4f2d 100644
> --- a/drivers/mfd/lp873x.c
> +++ b/drivers/mfd/lp873x.c
> @@ -53,8 +53,8 @@ static int lp873x_probe(struct i2c_client *client)
>  
>  	i2c_set_clientdata(client, lp873);
>  
> -	ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
> -			      ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
> +	ret = devm_mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
> +				   ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
>  
>  	return ret;

Same here.

-- 
Lee Jones

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

end of thread, other threads:[~2026-12-02 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 13:28 [PATCH 0/2] mfd: Remove LP873x and TPS65218 child devices on teardown Tian Xuechen
2026-11-26 13:28 ` [PATCH 1/2] mfd: lp873x: Remove the child devices on unbind Tian Xuechen
2026-12-02 16:26   ` Lee Jones
2026-11-26 13:28 ` [PATCH 2/2] mfd: tps65218: Fix potential use-after-free by child devices Tian Xuechen
2026-12-02 16:26   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox