Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp680022ybm; Thu, 28 May 2020 12:25:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8sgvK5lnXceISlzshIZNHFb3CYbkQcIX1VVC1tNf3eYrOGMq4v2o8ttT+QoxhyisMkbkz X-Received: by 2002:a17:906:1f8b:: with SMTP id t11mr4496884ejr.201.1590693916902; Thu, 28 May 2020 12:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590693916; cv=none; d=google.com; s=arc-20160816; b=ekPFEE4rbqZuVYLcWfaikCRyJBVZwQILoXa4hTe9EWLHsXbqJZV55YEMQP5000TRHS LN5Uf2k0rLUv27Hq0xJvN3tojjbia8Jvcv2jaVs6SdRSnMt/vHmO/u7Wvr+y7mF7iSz2 EMeUQu3OPNn97URU/URKlr0MEGSUf9KOruEFBd0lW1STdLa25Z6UfM3nmxIb2xaoH5rZ 4wCSQ9PpRVvrohojE6TzRRSIenG7i1iQc+Fh+dwYMBUI2qm6sRFnGZYBVcTTNtnqkSdC jtoz2ZSu/naAlbbFuu51mb7xIFr75G72Mu+kX0tO66G3g1N5IZzCzEzA9Tt0itmfqDo1 euYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Nka29i7ZJUncLJA5+jGZnopeHa7xaP+oiN0lDdrMLss=; b=AZ5I4omgLcDE2NK0LXjT6xA+c/tHcN80kMjpCCa9OlNATRGZMzXru7Dz7S0ATw4baa btXmX36g/fRQxaQVQRoSlnBagWZPIToPt+I7SDL4SW5ssURTbVbPhx+W7J/zx7+ia5Uy CO4YMx5LQYiPM1MFSFaS4fS8/Qhsd0MSC7faay0pHl2JIEBiufHazELnyPWa2Y8iy6KF S/w3hFZ2Xc/IXuUUU+rHbapffTd7ubcTJ+GiYrX/R7MSPl56v+YNfWgopNKq+XR5ee58 qGy8pzFBuLxxrINnZzIO9oOqsjvcTIfWxBtxZQr4/uV9+KXvb91H/3yGw3PRFXi1mEcn 6P+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si237897edw.228.2020.05.28.12.24.51; Thu, 28 May 2020 12:25:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406357AbgE1TV3 (ORCPT + 99 others); Thu, 28 May 2020 15:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406306AbgE1TVS (ORCPT ); Thu, 28 May 2020 15:21:18 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C397C08C5C6; Thu, 28 May 2020 12:21:18 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id E87022A41C0 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: "Rafael J . Wysocki" , Len Brown , Vishal Kulkarni , "David S . Miller" , Jiri Pirko , Ido Schimmel , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Kalle Valo , Peter Kaestle , Darren Hart , Andy Shevchenko , Sebastian Reichel , Miquel Raynal , Daniel Lezcano , Amit Kucheria , Support Opensource , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Heiko Stuebner , Orson Zhai , Baolin Wang , Chunyan Zhang , Zhang Rui , Allison Randal , Enrico Weigelt , Gayatri Kammela , Thomas Gleixner , Bartlomiej Zolnierkiewicz , Andrzej Pietrasiewicz , kernel@collabora.com Subject: [PATCH v4 01/11] acpi: thermal: Fix error handling in the register function Date: Thu, 28 May 2020 21:20:41 +0200 Message-Id: <20200528192051.28034-2-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528192051.28034-1-andrzej.p@collabora.com> References: <20200528192051.28034-1-andrzej.p@collabora.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The acpi_thermal_register_thermal_zone() is missing any error handling. This needs to be fixed. Signed-off-by: Andrzej Pietrasiewicz --- drivers/acpi/thermal.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 19067a5e5293..6de8066ca1e7 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -901,23 +901,35 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) result = sysfs_create_link(&tz->device->dev.kobj, &tz->thermal_zone->device.kobj, "thermal_zone"); if (result) - return result; + goto unregister_tzd; result = sysfs_create_link(&tz->thermal_zone->device.kobj, &tz->device->dev.kobj, "device"); if (result) - return result; + goto remove_tz_link; status = acpi_bus_attach_private_data(tz->device->handle, tz->thermal_zone); - if (ACPI_FAILURE(status)) - return -ENODEV; + if (ACPI_FAILURE(status)) { + result = -ENODEV; + goto remove_dev_link; + } tz->tz_enabled = 1; dev_info(&tz->device->dev, "registered as thermal_zone%d\n", tz->thermal_zone->id); + return 0; + +remove_dev_link: + sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); +remove_tz_link: + sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); +unregister_tzd: + thermal_zone_device_unregister(tz->thermal_zone); + + return result; } static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) -- 2.17.1