linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] firmware: arm_scmi: Fix NULL pointer dereference in mailbox_clear_channel
@ 2023-08-29 17:07 Qiujun Huang
  2023-08-30  9:39 ` Sudeep Holla
  0 siblings, 1 reply; 5+ messages in thread
From: Qiujun Huang @ 2023-08-29 17:07 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi, linux-arm-kernel, linux-kernel

There is a race between the failure of probe and rx_callback (due to a
delayed response).

scmi_probe
scmi_acquire_protocal
do_xfer
 timeout
mailbox_chan_free
                                                    <--- delay response
                                                           rx_callback
mbox_free_channel
cinfo->transport_info = NULL
                                                          mailbox_clear_channel
                                                         dereference cinfo->transport_info

This patch check for it, and clear the channel at mailbox_chan_free.

Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
 drivers/firmware/arm_scmi/mailbox.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/mailbox.c b/drivers/firmware/arm_scmi/mailbox.c
index 19246ed1f01f..32c5fe0b8c29 100644
--- a/drivers/firmware/arm_scmi/mailbox.c
+++ b/drivers/firmware/arm_scmi/mailbox.c
@@ -230,6 +230,7 @@ static int mailbox_chan_free(int id, void *p, void *data)
 		smbox->chan = NULL;
 		smbox->chan_receiver = NULL;
 		smbox->cinfo = NULL;
+		shmem_clear_channel(smbox->shmem);
 	}

 	return 0;
@@ -284,7 +285,8 @@ static void mailbox_clear_channel(struct scmi_chan_info *cinfo)
 {
 	struct scmi_mailbox *smbox = cinfo->transport_info;

-	shmem_clear_channel(smbox->shmem);
+	if (smbox)
+		shmem_clear_channel(smbox->shmem);
 }

 static bool
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-31 14:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-29 17:07 [PATCH v1] firmware: arm_scmi: Fix NULL pointer dereference in mailbox_clear_channel Qiujun Huang
2023-08-30  9:39 ` Sudeep Holla
2023-08-30 13:23   ` Qiujun Huang
2023-08-31 12:34     ` Sudeep Holla
2023-08-31 14:49       ` Qiujun Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).