From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796204086; b=zGATFqo6RJvezdip582amvSdrWvzyg5QHEOe85QhSRqlvaj89Fvj/r/oV+7tJzgQnZX+ p7g86ucfjFdc47lxzyn9gx7dj8dlLMUwJiw4aL20jAJPE93pJrjfCYZNAfd+48UWmOz9I 5fOZvILWcnc9e1RWGDcYBlq9fJXW4hWdC26x43Twqr0a3R6ZVw7ziG20Wxawq0X+pBJze md/Q2kPJvc1OD4Xtpfz49VmR98R6jNFAhkpc2mfRRMveGeTcJrvebbaWwXdiOCsOg/z5V CTsaQxIcXgSqQBRi53+ZiThPsr/zVuSbDxmI4jIDycnBUx51dvdvcj5BDKlZegxDusg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796204086; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=CJYumr1aNkCETk8ci3lNJNh7ShSfls6Cq7iEXTwWaDM=; b=SipZqU1n5bfS12NT1ADatKu/c8sj3Tjr7pncSZlM96/KrpjgK2Uy4EqEJeI8Nra7ZPKu sXQv/aZVjOP7SBSOxZV5YtjqmibteoeD6ZL/wzrr5bHQ6s5nMr+p9NZhs2SMLZAvpQP1T Qjcjf6Rf9SiKTU1IDAnQiHLtuSZyvNB2gDhgWFKeuplrFeteQ4ha1ceevi7+iQ3XMKEjj Y4Tl7M1zjIN90S/J86cbxO+SFB24s0STpN0aieElza2kiMdATnvJsPueNtFuBH7yQ9LPA Ku+D1iXlPm6W4d5dQkxet1D2PVBv6Q/er0wbC6KsweDrrzj3bx8AAUoQEG2M/Pm/7mg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TemY9plv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2DC4606A31A; Wed, 2 Dec 2026 09:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TemY9plv 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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