From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Krzysztof Kozlowski <krzk@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Jean-Jacques Hiblot <jjhiblot@traphandler.com>,
Boris Brezillon <bbrezillon@kernel.org>,
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 [thread overview]
Message-ID: <59d99bd5599d20463ee79676caf2e94d9cc4ff26.1796203994.git.lee@kernel.org> (raw)
In-Reply-To: <cover.1796203994.git.lee@kernel.org>
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 <lee@kernel.org>
---
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 <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regmap.h>
+#include <linux/slab.h>
#include <soc/at91/atmel-sfr.h>
#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
next prev parent reply other threads:[~2026-12-02 9:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 9:33 [PATCH 0/8] memory: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-02 9:33 ` Lee Jones [this message]
2026-12-02 9:33 ` [PATCH 3/8] memory: stm32_omm: Depopulate child devices before disabling clocks Lee Jones
2026-12-02 9:33 ` [PATCH 4/8] memory: stm32_omm: Fix double FIELD_PREP() and clamp for REQ2ACK Lee Jones
2026-12-02 9:33 ` [PATCH 5/8] memory: stm32_omm: Avoid division by zero in req2ack calculation Lee Jones
2026-12-02 9:33 ` [PATCH 6/8] memory: stm32_omm: Shift and mask AMCR value in stm32_omm_set_amcr() Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=59d99bd5599d20463ee79676caf2e94d9cc4ff26.1796203994.git.lee@kernel.org \
--to=lee@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=bbrezillon@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=jjhiblot@traphandler.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox