public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] platform: fix reference leak on failed platform_device_register()
@ 2026-05-04 10:08 Vastargazing
  2026-05-04 10:08 ` [PATCH 1/5] misc: eeprom: digsy_mtc: fix reference leak on failed device registration Vastargazing
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Vastargazing @ 2026-05-04 10:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: Vastargazing

platform_device_register() calls device_initialize() before
platform_device_add(). If platform_device_add() fails, device_initialize()
has already set the struct device kref to 1, and the kref must be released
via platform_device_put(). The kernel-doc for platform_device_register()
states this explicitly:

  NOTE: _Never_ directly free @pdev after calling this function, even if
  it returned an error! Always use platform_device_put() to give up the
  reference initialised in this function instead.

This series fixes five drivers that call platform_device_register() and
return the error code without calling platform_device_put() on the failure
path. The pattern was identified by Coccinelle static analysis, confirmed
by manual inspection, and is analogous to the recently merged fix in
commit 4ff036f95238 ("ALSA: pcmtest: fix reference leak on failed device
registration").

Sites fixed:
  drivers/misc/eeprom/digsy_mtc_eeprom.c
  drivers/platform/chrome/cros_ec_lpc.c
  drivers/mtd/maps/physmap-core.c
  drivers/perf/arm_pmu_acpi.c
  drivers/mfd/sm501.c

Build tested on x86 defconfig:
  - digsy_mtc_eeprom.c: compiled cleanly
  - cros_ec_lpc.c:       compiled cleanly
  - sm501.c:             compiled cleanly
  - physmap-core.c:      pre-existing Werror in map.h header (unrelated)
  - arm_pmu_acpi.c:      ARM-only, no asm/cputype.h on x86

Vastargazing (5):
  misc: eeprom: digsy_mtc: fix reference leak on failed device
    registration
  platform/chrome: cros_ec_lpc: fix reference leak on failed device
    registration
  mtd: maps: physmap: fix reference leak on failed device registration
  perf: arm: pmu: fix reference leak on failed device registration
  mfd: sm501: fix reference leak on failed device registration

 drivers/mfd/sm501.c                    | 4 +++-
 drivers/misc/eeprom/digsy_mtc_eeprom.c | 4 +++-
 drivers/mtd/maps/physmap-core.c        | 4 +++-
 drivers/perf/arm_pmu_acpi.c            | 4 +++-
 drivers/platform/chrome/cros_ec_lpc.c  | 1 +
 5 files changed, 13 insertions(+), 4 deletions(-)

-- 
2.51.0


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

* [PATCH 1/5] misc: eeprom: digsy_mtc: fix reference leak on failed device registration
  2026-05-04 10:08 [PATCH 0/5] platform: fix reference leak on failed platform_device_register() Vastargazing
@ 2026-05-04 10:08 ` Vastargazing
  2026-05-04 10:08 ` [PATCH 2/5] platform/chrome: cros_ec_lpc: " Vastargazing
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Vastargazing @ 2026-05-04 10:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vastargazing, stable, Arnd Bergmann, Greg Kroah-Hartman,
	Anatolij Gustschin, Andrew Morton

When platform_device_register() fails in digsy_mtc_eeprom_devices_init(),
the embedded struct device has already been initialized by
device_initialize() inside platform_device_register(). The failure path
cleans up the software node but returns the error without dropping the
device reference:

  digsy_mtc_eeprom_devices_init()
    -> platform_device_register(&digsy_mtc_eeprom)
       -> device_initialize(&digsy_mtc_eeprom.dev)   /* kref = 1 */
       -> platform_device_add(&digsy_mtc_eeprom)     /* fails */
    <- returns error, kref still 1, reference leaked

Per platform_device_register() kernel-doc:

  NOTE: _Never_ directly free @pdev after calling this function, even if
  it returned an error! Always use platform_device_put() to give up the
  reference initialised in this function instead.

Fix this by calling platform_device_put() in the error branch before
removing the software node.

Fixes: 469dded18391 ("misc/eeprom: add eeprom access driver for digsy_mtc board")
Cc: stable@vger.kernel.org
Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
Signed-off-by: Vastargazing <vebohr@gmail.com>
---
 drivers/misc/eeprom/digsy_mtc_eeprom.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/eeprom/digsy_mtc_eeprom.c b/drivers/misc/eeprom/digsy_mtc_eeprom.c
index ee58f7ce5bfa..4ca3e567c49d 100644
--- a/drivers/misc/eeprom/digsy_mtc_eeprom.c
+++ b/drivers/misc/eeprom/digsy_mtc_eeprom.c
@@ -89,8 +89,10 @@ static int __init digsy_mtc_eeprom_devices_init(void)
 		return ret;
 
 	ret = platform_device_register(&digsy_mtc_eeprom);
-	if (ret)
+	if (ret) {
+		platform_device_put(&digsy_mtc_eeprom);
 		device_remove_software_node(&digsy_mtc_eeprom.dev);
+	}
 
 	return ret;
 }
-- 
2.51.0


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

* [PATCH 2/5] platform/chrome: cros_ec_lpc: fix reference leak on failed device registration
  2026-05-04 10:08 [PATCH 0/5] platform: fix reference leak on failed platform_device_register() Vastargazing
  2026-05-04 10:08 ` [PATCH 1/5] misc: eeprom: digsy_mtc: fix reference leak on failed device registration Vastargazing
@ 2026-05-04 10:08 ` Vastargazing
  2026-05-05  2:40   ` Tzung-Bi Shih
  2026-05-04 10:08 ` [PATCH 3/5] mtd: maps: physmap: " Vastargazing
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Vastargazing @ 2026-05-04 10:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vastargazing, stable, Benson Leung, Tzung-Bi Shih, Guenter Roeck,
	Gwendal Grignou, Thierry Escande, Enric Balletbo i Serra,
	chrome-platform

When platform_device_register() fails in cros_ec_lpc_init(), the embedded
struct device has already been initialized by device_initialize() inside
platform_device_register(). The error path unregisters the driver but
returns without dropping the device reference:

  cros_ec_lpc_init()
    -> platform_device_register(&cros_ec_lpc_device)
       -> device_initialize(&cros_ec_lpc_device.dev)   /* kref = 1 */
       -> platform_device_add(&cros_ec_lpc_device)     /* fails */
    <- platform_driver_unregister() called, but kref still 1

Per platform_device_register() kernel-doc:

  NOTE: _Never_ directly free @pdev after calling this function, even if
  it returned an error! Always use platform_device_put() to give up the
  reference initialised in this function instead.

Fix this by calling platform_device_put() before unregistering the driver.

Fixes: 5f454bdf6353 ("platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.")
Cc: stable@vger.kernel.org
Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
Signed-off-by: Vastargazing <vebohr@gmail.com>
---
 drivers/platform/chrome/cros_ec_lpc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 78cfff80cdea..cb3ff76d29e9 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -892,6 +892,7 @@ static int __init cros_ec_lpc_init(void)
 		ret = platform_device_register(&cros_ec_lpc_device);
 		if (ret) {
 			pr_err(DRV_NAME ": can't register device: %d\n", ret);
+			platform_device_put(&cros_ec_lpc_device);
 			platform_driver_unregister(&cros_ec_lpc_driver);
 		}
 	}
-- 
2.51.0


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

* [PATCH 3/5] mtd: maps: physmap: fix reference leak on failed device registration
  2026-05-04 10:08 [PATCH 0/5] platform: fix reference leak on failed platform_device_register() Vastargazing
  2026-05-04 10:08 ` [PATCH 1/5] misc: eeprom: digsy_mtc: fix reference leak on failed device registration Vastargazing
  2026-05-04 10:08 ` [PATCH 2/5] platform/chrome: cros_ec_lpc: " Vastargazing
@ 2026-05-04 10:08 ` Vastargazing
  2026-05-04 13:58   ` Miquel Raynal
  2026-05-04 10:08 ` [PATCH 4/5] perf: arm: pmu: " Vastargazing
  2026-05-04 10:08 ` [PATCH 5/5] mfd: sm501: " Vastargazing
  4 siblings, 1 reply; 10+ messages in thread
From: Vastargazing @ 2026-05-04 10:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vastargazing, stable, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, David Woodhouse, Lennert Buytenhek,
	linux-mtd

When platform_device_register() fails in physmap_init(), the embedded
struct device has already been initialized by device_initialize() inside
platform_device_register(). The error path unregisters the driver but
returns without dropping the device reference:

  physmap_init()
    -> platform_device_register(&physmap_flash)
       -> device_initialize(&physmap_flash.dev)   /* kref = 1 */
       -> platform_device_add(&physmap_flash)     /* fails */
    <- platform_driver_unregister() called, but kref still 1

Per platform_device_register() kernel-doc:

  NOTE: _Never_ directly free @pdev after calling this function, even if
  it returned an error! Always use platform_device_put() to give up the
  reference initialised in this function instead.

Fix this by calling platform_device_put() before unregistering the driver.

Fixes: 73566edf9b91 ("[MTD] Convert physmap to platform driver")
Cc: stable@vger.kernel.org
Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
Signed-off-by: Vastargazing <vebohr@gmail.com>
---
 drivers/mtd/maps/physmap-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index dcda7685fc99..45d79ca622c1 100644
--- a/drivers/mtd/maps/physmap-core.c
+++ b/drivers/mtd/maps/physmap-core.c
@@ -654,8 +654,10 @@ static int __init physmap_init(void)
 #ifdef CONFIG_MTD_PHYSMAP_COMPAT
 	if (err == 0) {
 		err = platform_device_register(&physmap_flash);
-		if (err)
+		if (err) {
+			platform_device_put(&physmap_flash);
 			platform_driver_unregister(&physmap_flash_driver);
+		}
 	}
 #endif
 
-- 
2.51.0


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

* [PATCH 4/5] perf: arm: pmu: fix reference leak on failed device registration
  2026-05-04 10:08 [PATCH 0/5] platform: fix reference leak on failed platform_device_register() Vastargazing
                   ` (2 preceding siblings ...)
  2026-05-04 10:08 ` [PATCH 3/5] mtd: maps: physmap: " Vastargazing
@ 2026-05-04 10:08 ` Vastargazing
  2026-05-04 10:08 ` [PATCH 5/5] mfd: sm501: " Vastargazing
  4 siblings, 0 replies; 10+ messages in thread
From: Vastargazing @ 2026-05-04 10:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vastargazing, stable, Will Deacon, Mark Rutland, Jeremy Linton,
	Sudeep Holla, Lorenzo Pieralisi, linux-arm-kernel,
	linux-perf-users

When platform_device_register() fails in arm_acpi_register_pmu_device(),
the embedded struct device has already been initialized by
device_initialize() inside platform_device_register(). The error path
unregisters the GSI interrupt but returns without dropping the device
reference:

  arm_acpi_register_pmu_device()
    -> platform_device_register(pdev)
       -> device_initialize(&pdev->dev)   /* kref = 1 */
       -> platform_device_add(pdev)       /* fails */
    <- acpi_unregister_gsi() called, but kref still 1

Per platform_device_register() kernel-doc:

  NOTE: _Never_ directly free @pdev after calling this function, even if
  it returned an error! Always use platform_device_put() to give up the
  reference initialised in this function instead.

Fix this by calling platform_device_put() in the error branch before
unregistering the GSI.

Fixes: d24a0c7099b3 ("arm_pmu: acpi: spe: Add initial MADT/SPE probing")
Cc: stable@vger.kernel.org
Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
Signed-off-by: Vastargazing <vebohr@gmail.com>
---
 drivers/perf/arm_pmu_acpi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
index e80f76d95e68..c2defbc32ad9 100644
--- a/drivers/perf/arm_pmu_acpi.c
+++ b/drivers/perf/arm_pmu_acpi.c
@@ -119,8 +119,10 @@ arm_acpi_register_pmu_device(struct platform_device *pdev, u8 len,
 
 	pdev->resource[0].start = irq;
 	ret = platform_device_register(pdev);
-	if (ret)
+	if (ret) {
+		platform_device_put(pdev);
 		acpi_unregister_gsi(gsi);
+	}
 
 	return ret;
 }
-- 
2.51.0


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

* [PATCH 5/5] mfd: sm501: fix reference leak on failed device registration
  2026-05-04 10:08 [PATCH 0/5] platform: fix reference leak on failed platform_device_register() Vastargazing
                   ` (3 preceding siblings ...)
  2026-05-04 10:08 ` [PATCH 4/5] perf: arm: pmu: " Vastargazing
@ 2026-05-04 10:08 ` Vastargazing
  2026-05-04 12:48   ` [PATCH v2] " Valery Borovsky
  4 siblings, 1 reply; 10+ messages in thread
From: Vastargazing @ 2026-05-04 10:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vastargazing, stable, Lee Jones, Vincent Sanders, Andrew Morton,
	Ben Dooks

When platform_device_register() fails in sm501_register_device(), the
platform device allocated by sm501_create_subdev() has its struct device
initialized by device_initialize() inside platform_device_register(). The
error path logs the error but returns without dropping the device reference,
leaking the memory allocated by sm501_create_subdev():

  sm501_register_device()
    -> platform_device_register(pdev)
       -> device_initialize(&pdev->dev)   /* kref = 1 */
       -> platform_device_add(pdev)       /* fails */
    <- dev_err() called, kref still 1, sm501_device_release never called

The device's release callback (sm501_device_release) calls kfree() on the
containing sm501_device structure. Without platform_device_put(), this
memory is never freed.

Per platform_device_register() kernel-doc:

  NOTE: _Never_ directly free @pdev after calling this function, even if
  it returned an error! Always use platform_device_put() to give up the
  reference initialised in this function instead.

Fix this by calling platform_device_put() in the error branch, which
triggers sm501_device_release() and frees the allocated memory.

Fixes: b6d6454fdb66 ("[PATCH] mfd: SM501 core driver")
Cc: stable@vger.kernel.org
Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
Signed-off-by: Vastargazing <vebohr@gmail.com>
---
 drivers/mfd/sm501.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 0ee6d8940e69..8276456b142f 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -704,9 +704,11 @@ static int sm501_register_device(struct sm501_devdata *sm,
 	if (ret >= 0) {
 		dev_dbg(sm->dev, "registered %s\n", pdev->name);
 		list_add_tail(&smdev->list, &sm->devices);
-	} else
+	} else {
 		dev_err(sm->dev, "error registering %s (%d)\n",
 			pdev->name, ret);
+		platform_device_put(pdev);
+	}
 
 	return ret;
 }
-- 
2.51.0


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

* [PATCH v2] mfd: sm501: fix reference leak on failed device registration
  2026-05-04 10:08 ` [PATCH 5/5] mfd: sm501: " Vastargazing
@ 2026-05-04 12:48   ` Valery Borovsky
  2026-05-04 13:52     ` Miquel Raynal
  0 siblings, 1 reply; 10+ messages in thread
From: Valery Borovsky @ 2026-05-04 12:48 UTC (permalink / raw)
  To: Lee Jones
  Cc: Ben Dooks, Vincent Sanders, Andrew Morton, linux-kernel,
	Valery Borovsky, stable

When platform_device_register() fails in sm501_register_device(), the
platform device allocated by sm501_create_subdev() has its struct device
initialized by device_initialize() inside platform_device_register(). The
error path logs the error but returns without dropping the device reference,
leaking the memory allocated by sm501_create_subdev():

  sm501_register_device()
    -> platform_device_register(pdev)
       -> device_initialize(&pdev->dev)   /* kref = 1 */
       -> platform_device_add(pdev)       /* fails */
    <- dev_err() called, kref still 1, sm501_device_release never called

The device's release callback (sm501_device_release) calls kfree() on the
containing sm501_device structure. Without platform_device_put(), this
memory is never freed.

Per platform_device_register() kernel-doc:

  NOTE: _Never_ directly free @pdev after calling this function, even if
  it returned an error! Always use platform_device_put() to give up the
  reference initialised in this function instead.

Fix this by calling platform_device_put() in the error branch, which
triggers sm501_device_release() and frees the allocated memory.

Fixes: b6d6454fdb66 ("[PATCH] mfd: SM501 core driver")
Cc: stable@vger.kernel.org
Signed-off-by: Valery Borovsky <vebohr@gmail.com>
---
 drivers/mfd/sm501.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 0ee6d8940e69..8276456b142f 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -704,9 +704,11 @@ static int sm501_register_device(struct sm501_devdata *sm,
 	if (ret >= 0) {
 		dev_dbg(sm->dev, "registered %s\n", pdev->name);
 		list_add_tail(&smdev->list, &sm->devices);
-	} else
+	} else {
 		dev_err(sm->dev, "error registering %s (%d)\n",
 			pdev->name, ret);
+		platform_device_put(pdev);
+	}
 
 	return ret;
 }
-- 
2.51.0


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

* Re: [PATCH v2] mfd: sm501: fix reference leak on failed device registration
  2026-05-04 12:48   ` [PATCH v2] " Valery Borovsky
@ 2026-05-04 13:52     ` Miquel Raynal
  0 siblings, 0 replies; 10+ messages in thread
From: Miquel Raynal @ 2026-05-04 13:52 UTC (permalink / raw)
  To: Lee Jones, Valery Borovsky
  Cc: Ben Dooks, Vincent Sanders, Andrew Morton, linux-kernel, stable

On Mon, 04 May 2026 15:48:41 +0300, Valery Borovsky wrote:
> When platform_device_register() fails in sm501_register_device(), the
> platform device allocated by sm501_create_subdev() has its struct device
> initialized by device_initialize() inside platform_device_register(). The
> error path logs the error but returns without dropping the device reference,
> leaking the memory allocated by sm501_create_subdev():
> 
>   sm501_register_device()
>     -> platform_device_register(pdev)
>        -> device_initialize(&pdev->dev)   /* kref = 1 */
>        -> platform_device_add(pdev)       /* fails */
>     <- dev_err() called, kref still 1, sm501_device_release never called
> 
> [...]

Applied to mtd/next, thanks!

[1/1] mfd: sm501: fix reference leak on failed device registration
      commit: faa9bba3fe2f37e7dcb26d4501d890fbfd7df160

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl


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

* Re: [PATCH 3/5] mtd: maps: physmap: fix reference leak on failed device registration
  2026-05-04 10:08 ` [PATCH 3/5] mtd: maps: physmap: " Vastargazing
@ 2026-05-04 13:58   ` Miquel Raynal
  0 siblings, 0 replies; 10+ messages in thread
From: Miquel Raynal @ 2026-05-04 13:58 UTC (permalink / raw)
  To: Vastargazing
  Cc: linux-kernel, stable, Richard Weinberger, Vignesh Raghavendra,
	David Woodhouse, Lennert Buytenhek, linux-mtd

On 04/05/2026 at 13:08:45 +03, Vastargazing <vebohr@gmail.com> wrote:

> When platform_device_register() fails in physmap_init(), the embedded
> struct device has already been initialized by device_initialize() inside
> platform_device_register(). The error path unregisters the driver but
> returns without dropping the device reference:
>
>   physmap_init()
>     -> platform_device_register(&physmap_flash)
>        -> device_initialize(&physmap_flash.dev)   /* kref = 1 */
>        -> platform_device_add(&physmap_flash)     /* fails */
>     <- platform_driver_unregister() called, but kref still 1
>
> Per platform_device_register() kernel-doc:
>
>   NOTE: _Never_ directly free @pdev after calling this function, even if
>   it returned an error! Always use platform_device_put() to give up the
>   reference initialised in this function instead.
>
> Fix this by calling platform_device_put() before unregistering the driver.
>
> Fixes: 73566edf9b91 ("[MTD] Convert physmap to platform driver")
> Cc: stable@vger.kernel.org
> Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
> Signed-off-by: Vastargazing <vebohr@gmail.com>

Somehow b4 applied another patch from that series, I'm not sure why. I
just dropped it. Please resend this patch alone.

Also, your SoB line seems to be incorrect, we need a proper name, please
have a loot at the DCO.

Thanks,
Miquèl

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

* Re: [PATCH 2/5] platform/chrome: cros_ec_lpc: fix reference leak on failed device registration
  2026-05-04 10:08 ` [PATCH 2/5] platform/chrome: cros_ec_lpc: " Vastargazing
@ 2026-05-05  2:40   ` Tzung-Bi Shih
  0 siblings, 0 replies; 10+ messages in thread
From: Tzung-Bi Shih @ 2026-05-05  2:40 UTC (permalink / raw)
  To: Vastargazing
  Cc: linux-kernel, stable, Benson Leung, Guenter Roeck,
	Gwendal Grignou, Thierry Escande, Enric Balletbo i Serra,
	chrome-platform

On Mon, May 04, 2026 at 01:08:44PM +0300, Vastargazing wrote:
> When platform_device_register() fails in cros_ec_lpc_init(), the embedded
> struct device has already been initialized by device_initialize() inside
> platform_device_register(). The error path unregisters the driver but
> returns without dropping the device reference:
> 
>   cros_ec_lpc_init()
>     -> platform_device_register(&cros_ec_lpc_device)
>        -> device_initialize(&cros_ec_lpc_device.dev)   /* kref = 1 */
>        -> platform_device_add(&cros_ec_lpc_device)     /* fails */
>     <- platform_driver_unregister() called, but kref still 1
> 
> Per platform_device_register() kernel-doc:
> 
>   NOTE: _Never_ directly free @pdev after calling this function, even if
>   it returned an error! Always use platform_device_put() to give up the
>   reference initialised in this function instead.
> 
> Fix this by calling platform_device_put() before unregistering the driver.
> 
> Fixes: 5f454bdf6353 ("platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.")
> Cc: stable@vger.kernel.org
> Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
> Signed-off-by: Vastargazing <vebohr@gmail.com>
> ---
>  drivers/platform/chrome/cros_ec_lpc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
> index 78cfff80cdea..cb3ff76d29e9 100644
> --- a/drivers/platform/chrome/cros_ec_lpc.c
> +++ b/drivers/platform/chrome/cros_ec_lpc.c
> @@ -892,6 +892,7 @@ static int __init cros_ec_lpc_init(void)
>  		ret = platform_device_register(&cros_ec_lpc_device);
>  		if (ret) {
>  			pr_err(DRV_NAME ": can't register device: %d\n", ret);
> +			platform_device_put(&cros_ec_lpc_device);
>  			platform_driver_unregister(&cros_ec_lpc_driver);
>  		}
>  	}

The patch is identical to [1].  See also [2].

[1] https://lore.kernel.org/chrome-platform/20260415175707.3640225-1-lgs201920130244@gmail.com/
[2] https://lore.kernel.org/chrome-platform/CANUHTR9_c=msO7mAax=Aj4U--GB=2ozserOvrTU8WueqdSMN8Q@mail.gmail.com/

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

end of thread, other threads:[~2026-05-05  2:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 10:08 [PATCH 0/5] platform: fix reference leak on failed platform_device_register() Vastargazing
2026-05-04 10:08 ` [PATCH 1/5] misc: eeprom: digsy_mtc: fix reference leak on failed device registration Vastargazing
2026-05-04 10:08 ` [PATCH 2/5] platform/chrome: cros_ec_lpc: " Vastargazing
2026-05-05  2:40   ` Tzung-Bi Shih
2026-05-04 10:08 ` [PATCH 3/5] mtd: maps: physmap: " Vastargazing
2026-05-04 13:58   ` Miquel Raynal
2026-05-04 10:08 ` [PATCH 4/5] perf: arm: pmu: " Vastargazing
2026-05-04 10:08 ` [PATCH 5/5] mfd: sm501: " Vastargazing
2026-05-04 12:48   ` [PATCH v2] " Valery Borovsky
2026-05-04 13:52     ` Miquel Raynal

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