On Thu, Jun 24, 2021 at 06:50:56PM +0800, lijian_8010a29@xxxxxxx wrote: > From: lijian <lijian@xxxxxxxxxx> > > The 'data->pkt_tx_buff' is used after called > ‘kfree(data->pkt_tx_buff)’,it may be null when it is called, > and null pointer exception may occur, > so judgment is added when using 'data->pkt_tx_buff'. > - if (data->cur_trans->tx_buf != NULL) { > + if ((data->cur_trans->tx_buf != NULL) && (data->pkt_tx_buff != NULL)) { > if (*bpw == 8) { > tx_buf = data->cur_trans->tx_buf; > for (j = 0; j < data->bpw_len; j++) > @@ -621,8 +621,10 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw) > __func__); > pch_spi_writereg(data->master, PCH_SSNXCR, SSN_LOW); > > - for (j = 0; j < n_writes; j++) > - pch_spi_writereg(data->master, PCH_SPDWR, data->pkt_tx_buff[j]); > + if (data->pkt_tx_buff != NULL) { > + for (j = 0; j < n_writes; j++) I've not checked to make sure that the dereference can happen but if it does and these checks prevent dereferences it seems that they do so by simply skipping the writes that were happening which will result in the driver just silently dropping data, probably creating serious problems for whatever SPI device is attached. We should ideally carry on with the transmit, or at the very least return an error if things fail.
Attachment:
signature.asc
Description: PGP signature