Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5896252rdb; Thu, 14 Dec 2023 02:52:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZri6gSRFPp591IYZD3VVOMI43uFeVzs2TTIu3WDHU+A8IkxwhUvLbhdTIpduyxg++Sf4I X-Received: by 2002:a05:6a20:5492:b0:18c:90b1:7bdf with SMTP id i18-20020a056a20549200b0018c90b17bdfmr13072564pzk.53.1702551163432; Thu, 14 Dec 2023 02:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702551163; cv=none; d=google.com; s=arc-20160816; b=qAG4rNKLAoVG7XF/RvvIWiWgmeCSt/UvhvAfQJtUWIeWwuT0Gli5OR6qBNjVNRZD/K M/kSEhyOD950GcOB0SIQ/y0y3KnujC5kPqJQoZhPBGeNBwZRThCivXcIpCb8lOC27F5m Dal8l7W+zf/QbQi/3eruiuljgu/3zrRG2e0YtMuPhaeBLP06yaXFDIx3aCo7zE5O0zl2 o4TdHKL1inX7S+YT2aYRKvskZp64VsVHt8mHYAbS4EC2h/ZuwtW25iiI7sT9gE+fcWW1 Qk9XCjPQwyunBKAb2vGGx/4MMbL4Xu8OkO7TGK8vYyJBRpfV8p18dsO8dHFSjuqOGo2H jqGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=CQV8JjfxQ+sGZGn6RtAsk9JhwP9Dl2LijMaXH8ztClc=; fh=0LAKsbFkCSQWfu1i8y+7iTZd2YfKgOu80rNU4A+KQM0=; b=ixdgNQ0SmiCY++CcXj4PhbsCZ4t1eLXwAy3t5xk+VzK9zj0bWT3tXzE4oB9BRkz2+h hIilR8UI9OXC8uruO93nl1QL5nvD6gh6E2YhRawNTOByKHt/jUmrwxPT5hezVgNs3klL hM7KHs5It6QawaUxuQvgTmVX44zn/hxJFlpJJj6FjUkSazIGJzUFrISdMl7KNnnrpPj0 2/CgGtNr/n+TG+B1s0eVAtKqBGcI2knBlYo2z2HngZDM9LXLo2YCSidobKC+5BkakTUK GUQFu5PTN1NdWPgtgGViK5oelwM6vMbldm7wo8ZRLkg/N0KdMvpPXw7qw4C2qumHEl7K tBiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bz20-20020a056a02061400b005b95ee3edc6si11644362pgb.628.2023.12.14.02.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 02:52:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0E9778026A47; Thu, 14 Dec 2023 02:52:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443745AbjLNKwY (ORCPT + 99 others); Thu, 14 Dec 2023 05:52:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443734AbjLNKwX (ORCPT ); Thu, 14 Dec 2023 05:52:23 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 858C9BD; Thu, 14 Dec 2023 02:52:28 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id b379b9c677731927; Thu, 14 Dec 2023 11:52:26 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 0EEE86689E6; Thu, 14 Dec 2023 11:52:26 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM , Daniel Lezcano Cc: Srinivas Pandruvada , Zhang Rui , Linux ACPI , LKML , Lukasz Luba , Dan Carpenter Subject: [PATCH v1] thermal: core: Fix NULL pointer dereference in zone registration error path Date: Thu, 14 Dec 2023 11:52:25 +0100 Message-ID: <5737641.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrudelledgvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepffffffekgfehheffleetieevfeefvefhleetjedvvdeijeejledvieehueevueffnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepkedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthht oheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=8 Fuz1=8 Fuz2=8 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 02:52:41 -0800 (PST) From: Rafael J. Wysocki If device_register() in thermal_zone_device_register_with_trips() returns an error, the tz variable is set to NULL and subsequently dereferenced in kfree(tz->tzp). Commit adc8749b150c ("thermal/drivers/core: Use put_device() if device_register() fails") added the tz = NULL assignment in question to avoid a possible double-free after dropping the reference to the zone device. However, after commit 4649620d9404 ("thermal: core: Make thermal_zone_device_unregister() return after freeing the zone"), that assignment has become redundant, because dropping the reference to the zone device does not cause the zone object to be freed any more. Drop it to address the NULL pointer dereference. Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure") Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 1 - 1 file changed, 1 deletion(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -1394,7 +1394,6 @@ unregister: device_del(&tz->device); release_device: put_device(&tz->device); - tz = NULL; remove_id: ida_free(&thermal_tz_ida, id); free_tzp: