From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAC324F3937; Tue, 13 Oct 2026 12:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791894705; cv=none; b=ZRzevzZolGnlwJFb7+zdpKVNPoPJ2fULjqw23PiWCZhsr23V2EAgv5edfYlWDPoVs96lfxortHM7uzUd7jZN3g6gl21341H4wlYoriQLhtUcSo11UDRO0Dh6Ngbcb3eDhZmhfAUdVIcPmzV24ks1XcpxHtTNTJMS6e0SbT0qddM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791894705; c=relaxed/simple; bh=5T0SJqiEIEUlLb3hpHQULlThG1mCHn8CyI9LPQ4EKuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=asMEU/7jRmilCIFjMR0j3U/TcLRET8heXm8+XWLs7IlAHuQdUJkANqDFYAdpGWBiH+cSJXYx4d0oaopx9uI8S/p9DqTF3xPHXOB+kW2vKPSqKk4pWwlA4qCkL4T6RUin5xzruS4xtx+RvjhYe3nOP4QyeHH1nQyIHI06jmrPbeE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=erf43IiK; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="erf43IiK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22FFA1F000FF; Tue, 13 Oct 2026 12:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791894703; bh=IJkJo0eFyOZndA08L3ksP4kEfWnN8T7XF9r7vM8Lrhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=erf43IiKbDjZXwiwLHOx1Kz/Xc2m5UjVHzRVWeZTNVCYDODDdJ9hvSaI7XyFJZX60 jbeCkr67QlXrUzpDO51fkN8keIMF1qN7uKQZC984JrgO1AK6ypbTgQk3GYcUzdFcUU isjl+TYSKWPaMrA/UVhQNJ/yd5qg2bHP+WfSY+Ak= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Geert Uytterhoeven , Geert Uytterhoeven , Abdurrahman Hussain , "Rob Herring (Arm)" Subject: [PATCH 6.12 028/497] of/overlay: only treat a positive changeset id as registered Date: Tue, 13 Oct 2026 13:33:15 +0200 Message-ID: <20261013112908.554248110@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112907.864180619@linuxfoundation.org> References: <20261013112907.864180619@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Abdurrahman Hussain commit 44081d708b5b885487bac792db78324b7b4c267d upstream. of_overlay_fdt_apply() stores the idr_alloc() return value in ovcs->id before checking it. On failure the stored id is negative, free_overlay_changeset()'s "if (ovcs->id)" check passes, idr_remove() is called with a negative id and list_del() runs on ovcs->ovcs_list, which is not initialized until after the id allocation. An allocation failure at that point dereferences NULL. Make free_overlay_changeset() treat only a strict-positive id as registered. The rest of the function already copes with a partially-initialized ovcs, so the error path stays a plain goto err_free_ovcs. Fixes: 61b4de4e0b38 ("of: overlay: minor restructuring") Cc: stable@vger.kernel.org Suggested-by: Geert Uytterhoeven Assisted-by: Claude:claude-fable-5 [Claude Code] Reviewed-by: Geert Uytterhoeven Signed-off-by: Abdurrahman Hussain Link: https://patch.msgid.link/20260831-nh-of-alias-overlay-v7-5-02754604805a@nexthop.ai Signed-off-by: Rob Herring (Arm) Signed-off-by: Greg Kroah-Hartman --- drivers/of/overlay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -859,7 +859,8 @@ static void free_overlay_changeset(struc if (ovcs->cset.entries.next) of_changeset_destroy(&ovcs->cset); - if (ovcs->id) { + /* a failed idr_alloc() leaves its negative error in ovcs->id */ + if (ovcs->id > 0) { idr_remove(&ovcs_idr, ovcs->id); list_del(&ovcs->ovcs_list); ovcs->id = 0;