The MPFS mailbox driver declares priv_auto but also allocates a second
private data structure in the legacy probe path and overwrites the
device’s private pointer using dev_set_priv().
This results in leaking the auto-allocated private data and replacing
the driver’s private state mid-probe, which is incorrect usage of the
U-Boot Driver Model and can lead to undefined behavior.
Remove the redundant allocation and dev_set_priv() call so that the
driver consistently uses the auto-allocated private data provided by
U-Boot.
Fixes: 111e9bf6a5ac ("mailbox: add PolarFire SoC mailbox driver")
Signed-off-by: Jamie Gibbons <[email protected]>
---
drivers/mailbox/mpfs-mbox.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/mailbox/mpfs-mbox.c b/drivers/mailbox/mpfs-mbox.c
index 4a9465c7a72..2e20b08307c 100644
--- a/drivers/mailbox/mpfs-mbox.c
+++ b/drivers/mailbox/mpfs-mbox.c
@@ -135,10 +135,6 @@ static int mpfs_mbox_probe(struct udevice *dev)
node = dev_ofnode(dev);
- mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
- if (!mbox)
- return -ENOMEM;
-
ret = ofnode_read_resource(node, 0, ®s);
if (ret) {
dev_err(dev, "No reg property for controller base\n");
@@ -156,7 +152,6 @@ static int mpfs_mbox_probe(struct udevice *dev)
mbox->mbox_base = devm_ioremap(dev, res.start, resource_size(&res));
mbox->dev = dev;
- dev_set_priv(dev, mbox);
mbox->chan->con_priv = mbox;
return 0;
--
2.43.0