From ca62042a01dc8be05504632e21bbd09c4ae9a08d Mon Sep 17 00:00:00 2001 From: pshaw Date: Tue, 5 Sep 2023 07:59:39 +0000 Subject: [PATCH] fsicom: fix misra and cert-c issue - fix misra nad cert issue for the multi core code change Bug 3952896 Bug 3959323 Change-Id: Id3108a604aea71e4b2b75034a2852b3083ad8947 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2974001 Signed-off-by: pshaw Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2977128 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/platform/tegra/tegra-fsicom.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/platform/tegra/tegra-fsicom.c b/drivers/platform/tegra/tegra-fsicom.c index d0eff04b..27ff34fc 100644 --- a/drivers/platform/tegra/tegra-fsicom.c +++ b/drivers/platform/tegra/tegra-fsicom.c @@ -130,7 +130,7 @@ static int tegra_hsp_mb_init(struct device *dev) fsi_hsp_v[lCoreId]->rx.client.rx_callback = tegra_hsp_rx_notify; fsi_hsp_v[lCoreId]->tx.client.tx_done = tegra_hsp_tx_empty_notify; - snprintf(lTxStr, sizeof(lTxStr), "fsi-tx-cpu%d", lCoreId); + (void)snprintf(lTxStr, sizeof(lTxStr), "fsi-tx-cpu%d", lCoreId); fsi_hsp_v[lCoreId]->tx.chan = mbox_request_channel_byname( &fsi_hsp_v[lCoreId]->tx.client, lTxStr); @@ -140,7 +140,7 @@ static int tegra_hsp_mb_init(struct device *dev) return err; } - snprintf(lRxStr, sizeof(lRxStr), "fsi-rx-cpu%d", lCoreId); + (void)snprintf(lRxStr, sizeof(lRxStr), "fsi-rx-cpu%d", lCoreId); fsi_hsp_v[lCoreId]->rx.chan = mbox_request_channel_byname( &fsi_hsp_v[lCoreId]->rx.client, lRxStr); @@ -156,7 +156,7 @@ static int tegra_hsp_mb_init(struct device *dev) static int smmu_buff_map(unsigned long arg) { - u32 val; + u32 val = 0xFF; int ret; dma_addr_t dma_addr; dma_addr_t phys_addr; @@ -251,6 +251,8 @@ static ssize_t device_file_ioctl( if (copy_from_user(&input, (void __user *)arg, sizeof(struct rw_data))) return -EACCES; + if (input.coreid >= sgMaxCore) + return -ECHRNG; pdata[0] = input.handle; ret = mbox_send_message(fsi_hsp_v[input.coreid]->tx.chan, (void *)pdata); @@ -268,6 +270,9 @@ static ssize_t device_file_ioctl( if (copy_from_user(&ldata, (void __user *)arg, sizeof(struct iova_data))) return -EACCES; + if (ldata.coreid >= sgMaxCore) + return -ECHRNG; + pdata[0] = ldata.offset; pdata[1] = ldata.iova; pdata[2] = ldata.chid;