i2c: i2c-msm-geni: NULL check before accessing i2c message

This change adds a NULL pointer check for i2c rx callback function.
In some corner case and rare scenario, it may happen that delayed
callback from GSI for any unexpected sequence can result into accessing
stale message pointer which can be NULL.

Actual root cause should be found but this adds a protection check.

Change-Id: Iab2196812289026674ee3b26d27c4f20a01bbda2
Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
This commit is contained in:
Mukesh Kumar Savaliya 2022-03-25 00:41:22 +05:30
commit 894ebb20b0

View file

@ -513,6 +513,13 @@ static void gi2c_gsi_rx_cb(void *ptr)
struct msm_gpi_dma_async_tx_cb_param *rx_cb = ptr;
struct geni_i2c_dev *gi2c = rx_cb->userdata;
if (gi2c->cur == NULL) {
GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev,
"%s: Error: unexpected callback\n", __func__);
WARN_ON(1);
return;
}
if (gi2c->cur->flags & I2C_M_RD) {
gi2c_gsi_cb_err(rx_cb, "RX");
complete(&gi2c->xfer);