[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210624114430.GB3912@sirena.org.uk>
Date: Thu, 24 Jun 2021 12:44:31 +0100
From: Mark Brown <broonie@...nel.org>
To: lijian_8010a29@....com
Cc: linux-spi@...r.kernel.org, linux-kernel@...r.kernel.org,
lijian <lijian@...ong.com>
Subject: Re: [PATCH] spi: spi-topcliff-pch: Fixed the possible null pointer
exception issue
On Thu, Jun 24, 2021 at 06:50:56PM +0800, lijian_8010a29@....com wrote:
> From: lijian <lijian@...ong.com>
>
> 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.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists