firmware: arm_scmi: Free mailbox state on mapping failure
Sudeep Holla
maintainerPATCH 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.
--- drivers/firmware/arm_scmi/transports/mailbox.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/transports/mailbox.c +5 -2
@@ -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
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