[HUST CSE]fix:修改drv_spi.c空指针问题

This commit is contained in:
nobody 2023-04-29 20:50:21 +08:00 committed by Man, Jianting (Meco)
parent 8d526a72b4
commit 613e5a3e51
4 changed files with 38 additions and 9 deletions

View File

@ -393,8 +393,15 @@ static rt_ssize_t xfer(struct rt_spi_device* device, struct rt_spi_message* mess
/* calculate the start address */
already_send_length = message->length - send_length - message_length;
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
/* avoid null pointer problems */
if (message->send_buf)
{
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
}
if (message->recv_buf)
{
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
}
/* start once data exchange in dma mode */
if (message->send_buf && message->recv_buf)

View File

@ -441,8 +441,16 @@ static rt_uint32_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mes
/* calculate the start address */
already_send_length = message->length - send_length - message_length;
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
/* avoid null pointer problems */
if (message->send_buf)
{
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
}
if (message->recv_buf)
{
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
}
if (message->send_buf && message->recv_buf)
{
if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_RX))

View File

@ -329,9 +329,16 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
/* calculate the start address */
already_send_length = message->length - send_length - message_length;
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
/* avoid null pointer problems */
if (message->send_buf)
{
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
}
if (message->recv_buf)
{
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
}
#if defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32F7)
rt_uint32_t* dma_buf = RT_NULL;
if ((spi_drv->spi_dma_flag & SPI_USING_TX_DMA_FLAG) && (spi_drv->spi_dma_flag & SPI_USING_RX_DMA_FLAG))

View File

@ -410,8 +410,15 @@ static rt_ssize_t spi_xfer(struct rt_spi_device *device, struct rt_spi_message *
/* calculate the start address */
already_send_length = message->length - send_length - message_length;
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
/* avoid null pointer problems */
if (message->send_buf)
{
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
}
if (message->recv_buf)
{
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
}
/* start once data exchange */
if (message->send_buf && message->recv_buf)