From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E293606A334 for ; Wed, 2 Dec 2026 09:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=1syAOSvh; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TemY9plv DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=CJYumr1aNkCETk8ci3lNJNh7ShSfls6Cq7iEXTwWaDM=; b=1syAOSvh8X0FMI kAC/8y0g2BlmPTRTE0MBIX5sxJIGOHablc9rVSPhzbnZJokuKn4f4CR+TgND0j5mqH9wOqeOGmars G2xettepoFe3x6lMNxaitXoihHCbtC+Q81TeRRHV4PGM7Ujgbv3bzfSHN9YwGxvUfQ/zIMRCj5LFN XONhKEd7RaX/NSEG5X3sYqzTAgmAvmsAL+ALsmIlOqRjNUXXh8vg+tw1+B4o24FpZGbdG9wvzUPRX GN5QWg69pgLmFfQ/Kt+FUYQ2+OI+ubOTYsCqn/2fVf05fvAH1zrPsh5mbS85ybmdCL3QDeKoq2rtg 1PqQWJighiSHz95CAWkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYgjf-0000000ArGI-2xHp; Wed, 02 Dec 2026 09:34:47 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYgje-0000000ArG2-2hMT for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 09:34:46 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 5F42945308; Wed, 2 Dec 2026 09:34:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A43311F00ADD; Wed, 2 Dec 2026 09:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796204086; bh=CJYumr1aNkCETk8ci3lNJNh7ShSfls6Cq7iEXTwWaDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TemY9plv6pOCdnpV2erWGx5omRwyyUqM464M8+GFRGLO+SKR/HZqEfoD+UCTpE74D XeSEw23s2gJTaglO/xximNUdlnIc3squnkdQEwu5/nlX4k7HmXWb1s/6v3FpEh7pCg YjfnHBTGpL2U9tTxBQFEf1kT010nnDwKjh3Vypwq3QS8bV35kdblXUuKJpa1u/z3SE Pf6Yry4Jbi15O5ihIsN23uoIxHWS2OzSI8NxOfwUu5DdygtitUJvGLBjqwfaleabEr YzoQr8xtEuu5hvHIXmLIsENVkZLlgL3t4u4Pf7OoZ3Ss6JgwxZLsi8iGTdhi3/Juvv LBwIDNW80UVrA== From: Lee Jones To: lee@kernel.org, Krzysztof Kozlowski , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Jean-Jacques Hiblot , Boris Brezillon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: stable@vger.kernel.org Subject: [PATCH 1/8] memory: atmel-ebi: Use non-devm allocations for of_update_property() Date: Wed, 2 Dec 2026 09:33:48 +0000 Message-ID: <59d99bd5599d20463ee79676caf2e94d9cc4ff26.1796203994.git.lee@kernel.org> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 atmel_ebi_dev_disable() allocates the struct property and its name and value strings using devm_kzalloc() and devm_kstrdup(), then installs the property into the live device tree via of_update_property(). Because device tree properties outlive the platform device, a subsequent probe failure or device unbind frees those devm-managed allocations while the property remains linked in np->properties, causing a use-after-free on later device tree accesses. Switch atmel_ebi_dev_disable() to kzalloc_obj() and kstrdup() with proper kfree() unwinding on error, and drop the now-unused ebi parameter. Fixes: 6a4ec4cd0888 ("memory: add Atmel EBI (External Bus Interface) driver") Closes: https://sashiko.dev/#/bug/linux-2e85dceb-25c0-4065-b486-f6bdc0a88ca6 Cc: stable@vger.kernel.org Signed-off-by: Lee Jones --- drivers/memory/atmel-ebi.c | 40 +++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c index 33d7007d9d0c..89a5b5e8a334 100644 --- a/drivers/memory/atmel-ebi.c +++ b/drivers/memory/atmel-ebi.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #define AT91_EBI_NUM_CS 8 @@ -493,26 +494,43 @@ static const struct of_device_id atmel_ebi_id_table[] = { { /* sentinel */ } }; -static int atmel_ebi_dev_disable(struct atmel_ebi *ebi, struct device_node *np) +static int atmel_ebi_dev_disable(struct device_node *np) { - struct device *dev = ebi->dev; struct property *newprop; + int ret; - newprop = devm_kzalloc(dev, sizeof(*newprop), GFP_KERNEL); + newprop = kzalloc_obj(*newprop); if (!newprop) return -ENOMEM; - newprop->name = devm_kstrdup(dev, "status", GFP_KERNEL); - if (!newprop->name) - return -ENOMEM; + newprop->name = kstrdup("status", GFP_KERNEL); + if (!newprop->name) { + ret = -ENOMEM; + goto err_free_prop; + } - newprop->value = devm_kstrdup(dev, "disabled", GFP_KERNEL); - if (!newprop->value) - return -ENOMEM; + newprop->value = kstrdup("disabled", GFP_KERNEL); + if (!newprop->value) { + ret = -ENOMEM; + goto err_free_name; + } newprop->length = sizeof("disabled"); - return of_update_property(np, newprop); + ret = of_update_property(np, newprop); + if (ret) + goto err_free_value; + + return 0; + +err_free_value: + kfree(newprop->value); +err_free_name: + kfree(newprop->name); +err_free_prop: + kfree(newprop); + + return ret; } static int atmel_ebi_probe(struct platform_device *pdev) @@ -603,7 +621,7 @@ static int atmel_ebi_probe(struct platform_device *pdev) dev_err(dev, "failed to configure EBI bus for %pOF, disabling the device", child); - ret = atmel_ebi_dev_disable(ebi, child); + ret = atmel_ebi_dev_disable(child); if (ret) goto err_disable_clk; } -- 2.56.1.911.g883d8bcb20-goog