q2spi-msm-geni: Add defensive check for valid slave address

This change is to add logic to check for valid slave address from clients.

Change-Id: I80bd1c3bb8e0384ed29f36cd12c602e434dcb487
Signed-off-by: Chandana Kishori Chiluveru <quic_cchiluve@quicinc.com>
This commit is contained in:
Chandana Kishori Chiluveru 2023-10-31 04:59:36 -07:00
parent 4970692034
commit 91dcc8ffa0
2 changed files with 7 additions and 1 deletions

View File

@ -1379,6 +1379,11 @@ static ssize_t q2spi_transfer(struct file *filp, const char __user *buf, size_t
if (!q2spi_cmd_type_valid(q2spi_req))
return -EINVAL;
if (q2spi_req.addr > Q2SPI_SLAVE_END_ADDR) {
Q2SPI_ERROR(q2spi, "%s Err Invalid address:%x\n", __func__, q2spi_req.addr);
return -EINVAL;
}
if (q2spi_req.cmd == HRF_WRITE) {
q2spi_req.addr = Q2SPI_HRF_PUSH_ADDRESS;
q2spi_req.sync = 1;

View File

@ -24,7 +24,7 @@
#define Q2SPI_CLIENT_STATE 0x00000048
#define Q2SPI_RUNTIME_STATUS 0x0000004C
#define Q2SPI_TDB_FREE_SPACE 0x00000050
#define Q2SPI_SLAVE_ERROR 0x00000054
#define Q2SPI_SLAVE_ERROR 0x00000054
#define Q2SPI_HDR_ERROR 0x00000058
#define Q2SPI_ERROR_EN 0x0000005C
#define Q2SPI_SMA_DATA(n) (0x00000070 + (0x4 * (n)))
@ -33,4 +33,5 @@
#define Q2SPI_SMA_CTRL 0x00000088
#define Q2SPI_PURGE_COMPLETE 0x0000008C
#define Q2SPI_HOST_CFG 0x00000090
#define Q2SPI_SLAVE_END_ADDR 0x00000090
#endif /* _SPI_Q2SPI_SLAVE_H_ */