From patchwork Fri Jun 26 17:37:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11628191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2767E14F6 for ; Fri, 26 Jun 2020 17:38:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 014EB2088E for ; Fri, 26 Jun 2020 17:38:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2Bnr/8KM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 014EB2088E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KafRZ+WHNHHC5qedOcj0aKFebWW17PBxLZY9gN/NlFA=; b=2Bnr/8KMywp1oj8D96DNsi2EOD 2Qg9IiHCpgsWD9NHljbyzaJt6Yuo4/IkjE93ZzViiPvcz04Ag1TYpyUVv7FmLzf6hpfzbl0Y0IeqW VRAWdZkesZE8f6lyDnZGCIGRkLOPK1uxLAF1sFl11xcxM1+AHbYI4f0fnyMHrdq1l9WlcF5C/gbIZ JO1x4olpd7e4Rv2ddmmtmB442IY7FPrG6wnOow/Jx3zpsxhnPVdHf+q3lzfEm+muHAPq1OE1/e4OR FhNDUn6lg4+KHnqo84BffjioG9kWxTS6gy/DiyYCwscMhzJJSz6qE9ygVUAm7O94JCsrBfV07Wpia YxTFOlEg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1josJD-00020P-5Q; Fri, 26 Jun 2020 17:38:39 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1josIg-0001sP-PQ; Fri, 26 Jun 2020 17:38:07 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 2B6CC2A5E30 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 Subject: [PATCH v5 01/11] acpi: thermal: Fix error handling in the register function Date: Fri, 26 Jun 2020 19:37:45 +0200 Message-Id: <20200626173755.26379-2-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626173755.26379-1-andrzej.p@collabora.com> References: <9cbffad6-69e4-0b33-4640-fde7c4f6a6e7@linaro.org> <20200626173755.26379-1-andrzej.p@collabora.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emmanuel Grumbach , Heiko Stuebner , "Rafael J . Wysocki" , Vishal Kulkarni , Luca Coelho , Miquel Raynal , kernel@collabora.com, Fabio Estevam , Amit Kucheria , Chunyan Zhang , Daniel Lezcano , Allison Randal , NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Johannes Berg , Intel Linux Wireless , Sascha Hauer , Ido Schimmel , Baolin Wang , Jiri Pirko , Orson Zhai , Thomas Gleixner , Kalle Valo , Support Opensource , Enrico Weigelt , Peter Kaestle , Sebastian Reichel , Andrzej Pietrasiewicz , Bartlomiej Zolnierkiewicz , Pengutronix Kernel Team , =?utf-8?q?Niklas_S=C3=B6de?= =?utf-8?q?rlund?= , Shawn Guo , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The acpi_thermal_register_thermal_zone() is missing any error handling. This needs to be fixed. Signed-off-by: Andrzej Pietrasiewicz Reviewed-by: Guenter Roeck Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Amit Kucheria --- 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)