Skip to content

Commit 5d1451c

Browse files
bentheredonethatgregkh
authored andcommitted
remoteproc: xlnx: Only access buffer information if IPI is buffered
commit 38dd6cc upstream. In the receive callback check if message is NULL to prevent possibility of crash by NULL pointer dereferencing. Signed-off-by: Ben Levinsky <ben.levinsky@amd.com> Signed-off-by: Tanmay Shah <tanmay.shah@amd.com> Fixes: 5dfb28c ("remoteproc: xilinx: Add mailbox channels for rpmsg") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20260303235127.2317955-3-tanmay.shah@amd.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c9d2f7b commit 5d1451c

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

drivers/remoteproc/xlnx_r5_remoteproc.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,19 @@ static void zynqmp_r5_mb_rx_cb(struct mbox_client *cl, void *msg)
179179

180180
ipi = container_of(cl, struct mbox_info, mbox_cl);
181181

182-
/* copy data from ipi buffer to r5_core */
182+
/* copy data from ipi buffer to r5_core if IPI is buffered. */
183183
ipi_msg = (struct zynqmp_ipi_message *)msg;
184-
buf_msg = (struct zynqmp_ipi_message *)ipi->rx_mc_buf;
185-
len = ipi_msg->len;
186-
if (len > IPI_BUF_LEN_MAX) {
187-
dev_warn(cl->dev, "msg size exceeded than %d\n",
188-
IPI_BUF_LEN_MAX);
189-
len = IPI_BUF_LEN_MAX;
184+
if (ipi_msg) {
185+
buf_msg = (struct zynqmp_ipi_message *)ipi->rx_mc_buf;
186+
len = ipi_msg->len;
187+
if (len > IPI_BUF_LEN_MAX) {
188+
dev_warn(cl->dev, "msg size exceeded than %d\n",
189+
IPI_BUF_LEN_MAX);
190+
len = IPI_BUF_LEN_MAX;
191+
}
192+
buf_msg->len = len;
193+
memcpy(buf_msg->data, ipi_msg->data, len);
190194
}
191-
buf_msg->len = len;
192-
memcpy(buf_msg->data, ipi_msg->data, len);
193195

194196
/* received and processed interrupt ack */
195197
if (mbox_send_message(ipi->rx_chan, NULL) < 0)

0 commit comments

Comments
 (0)