Skip to contentSkip to conversation

platform: arm64: huawei-gaokun-ec: fix OF node leak

PATCH In review Johan Hovold 3 participants 3 messages Jul 8, 2025 – Jul 11, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform: arm64: huawei-gaokun-ec: fix OF node leak

Make sure to drop the OF node reference taken when creating the Gaokun auxiliary devices when the devices are later released.

Fixes 7636f090d02e ("platform: arm64: add Huawei Matebook E Go EC driver")
Cc Pengyu Luo <[email protected]>
---
 drivers/platform/arm64/huawei-gaokun-ec.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/platform/arm64/huawei-gaokun-ec.c +2 -0
index 7e5aa7ca2403..7170f8eb76f7 100644
@@ -662,6 +662,7 @@ static void gaokun_aux_release(struct device *dev)
 {
 	struct auxiliary_device *adev = to_auxiliary_dev(dev);
 
+	of_node_put(dev->of_node);
 	kfree(adev);
 }
 
@@ -693,6 +694,7 @@ static int gaokun_aux_init(struct device *parent, const char *name,
 
 	ret = auxiliary_device_init(adev);
 	if (ret) {
+		of_node_put(adev->dev.of_node);
 		kfree(adev);
 		return ret;
 	}
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Johan Hovold

Make sure to drop the OF node reference taken when creating the Gaokun auxiliary devices when the devices are later released.

Fixes 7636f090d02e ("platform: arm64: add Huawei Matebook E Go EC driver")
Cc Pengyu Luo <[email protected]>
---
 drivers/platform/arm64/huawei-gaokun-ec.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/platform/arm64/huawei-gaokun-ec.c +2 -1
index 7e5aa7ca2403..7170f8eb76f7 100644
@@ -662,6 +662,7 @@ static void gaokun_aux_release(struct device *dev)
 {
        struct auxiliary_device *adev = to_auxiliary_dev(dev);
 
+       of_node_put(dev->of_node);
        kfree(adev);
 }
 
@@ -693,6 +694,7 @@ static int gaokun_aux_init(struct device *parent, const char *name,
 
        ret = auxiliary_device_init(adev);
        if (ret) {
+               of_node_put(adev->dev.of_node);
                kfree(adev);
                return ret;
        }
--
Quoted 2 lines

2.49.0

Oh, I should have checked device_set_of_node_from_dev, but I forgot, thanks for fixing this.

Best wishes,
Pengyu

maintainer
#2 lore raw
In reply to Johan Hovold
Quoted 4 lines · Johan Hovold

Make sure to drop the OF node reference taken when creating the Gaokun auxiliary devices when the devices are later released.

Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/1] platform: arm64: huawei-gaokun-ec: fix OF node leak

      commit: bc48d79a1829ac5a79cc3d1eb8bf30c0ae9b3bcd

--
i.