From 7f5ea5e2fd102d26327517708daa90865fedece9 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 18 Jun 2021 19:20:50 +0200 Subject: [PATCH] mt7915: check return code of sysfs_create_link Signed-off-by: Felix Fietkau --- mt7915/init.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mt7915/init.c b/mt7915/init.c index 2aa7acac..a71c5249 100644 --- a/mt7915/init.c +++ b/mt7915/init.c @@ -134,9 +134,11 @@ static int mt7915_thermal_init(struct mt7915_phy *phy) cdev = thermal_cooling_device_register(wiphy_name(wiphy), phy, &mt7915_thermal_ops); if (!IS_ERR(cdev)) { - phy->cdev = cdev; - sysfs_create_link(&wiphy->dev.kobj, &cdev->device.kobj, - "cooling_device"); + if (sysfs_create_link(&wiphy->dev.kobj, &cdev->device.kobj, + "cooling_device") < 0) + thermal_cooling_device_unregister(cdev); + else + phy->cdev = cdev; } if (!IS_REACHABLE(CONFIG_HWMON))