Skip to contentSkip to conversation

firmware: arm_scmi: Free mailbox state on mapping failure

PATCH Applied Sudeep Holla 1 participant 2 messages Oct 28 – Nov 2 System control & power/management interface (SCPI/SCMI) Message Protocol drivers

lore
Share & tools
lore

Sudeep Holla

author maintainer
#0 lore raw

PATCH 1/1 firmware: arm_scmi: Free mailbox state on mapping failure

mailbox_chan_setup() allocates its private state from the SCMI base device before mapping the shared-memory area. If mapping fails while setting up an optional RX channel, the core ignores the RX failure and keeps the base device bound, retaining that devres allocation.

Release the private mailbox state before returning the mapping error.

Fixes 1ebc28e9357c ("firmware: arm_scmi: Introduce setup_shmem_iomap")
---
 drivers/firmware/arm_scmi/transports/mailbox.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/transports/mailbox.c +5 -2
index 56af2cb0f424..49c472e2ba27 100644
@@ -206,8 +206,11 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
 
 	smbox->shmem = core->shmem->setup_iomap(cinfo, dev, tx, NULL,
 						&smbox->io_ops);
-	if (IS_ERR(smbox->shmem))
-		return PTR_ERR(smbox->shmem);
+	if (IS_ERR(smbox->shmem)) {
+		ret = PTR_ERR(smbox->shmem);
+		devm_kfree(dev, smbox);
+		return ret;
+	}
 
 	cl = &smbox->cl;
 	cl->dev = cdev;
Signature · 1 line
2.43.0
author maintainer Applied
#1 lore raw
Quoted 8 lines · Sudeep Holla

mailbox_chan_setup() allocates its private state from the SCMI base device before mapping the shared-memory area. If mapping fails while setting up an optional RX channel, the core ignores the RX failure and keeps the base device bound, retaining that devres allocation.

Release the private mailbox state before returning the mapping error.

[...]

Applied to sudeep.holla/linux (for-next/scmi/fixes), thanks!

[1/1] firmware: arm_scmi: Free mailbox state on mapping failure

      https://git.kernel.org/sudeep.holla/c/38b6268eae65
Signature · 2 lines
Regards,
Sudeep