| Message ID | 20260827-i2c-dma-channel-leak-v1-3-271d4adc03a0@cherr.cc |
|---|---|
| State | New |
| Headers | show |
| Series | i2c: fix DMA channel leaks on probe error and remove | expand |
On 8/27/26 5:43 PM, Shengzhuo Wei wrote: > geni_i2c_init() grabs exclusive GPI tx/rx DMA channels when the serial > engine runs in GPI mode. If i2c_add_adapter() subsequently fails, probe > returns without releasing the channels, because the remove callback is > not invoked after a failed probe. > > The adapter-registration failure path used to release the channels via > its err_dma label; that release was dropped when the probe tail was > restructured into geni_i2c_init(). > > Release the channels on the adapter-registration failure path, mirroring > geni_i2c_remove(). > > Fixes: d8d3bb127ad1 ("i2c: qcom-geni: Isolate serial engine setup") > Cc: stable@vger.kernel.org > Signed-off-by: Shengzhuo Wei <me@cherr.cc> > Assisted-by: GLM:5.3 > --- Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Konrad
On 8/27/2026 9:13 PM, Shengzhuo Wei wrote: > geni_i2c_init() grabs exclusive GPI tx/rx DMA channels when the serial > engine runs in GPI mode. If i2c_add_adapter() subsequently fails, probe > returns without releasing the channels, because the remove callback is > not invoked after a failed probe. > > The adapter-registration failure path used to release the channels via > its err_dma label; that release was dropped when the probe tail was > restructured into geni_i2c_init(). > > Release the channels on the adapter-registration failure path, mirroring > geni_i2c_remove(). > > Fixes: d8d3bb127ad1 ("i2c: qcom-geni: Isolate serial engine setup") > Cc: stable@vger.kernel.org > Signed-off-by: Shengzhuo Wei <me@cherr.cc> > Assisted-by: GLM:5.3 > --- Reviewed-by: Mukesh Kumar Savaliya <mukesh.savaliya@oss.qualcomm.com>
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c index 658636c1ee0e..45c770552bd2 100644 --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -1189,8 +1189,10 @@ static int geni_i2c_probe(struct platform_device *pdev) return ret; ret = i2c_add_adapter(&gi2c->adap); - if (ret) + if (ret) { + release_gpi_dma(gi2c); return dev_err_probe(dev, ret, "Error adding i2c adapter\n"); + } dev_dbg(dev, "Geni-I2C adaptor successfully added\n");
geni_i2c_init() grabs exclusive GPI tx/rx DMA channels when the serial engine runs in GPI mode. If i2c_add_adapter() subsequently fails, probe returns without releasing the channels, because the remove callback is not invoked after a failed probe. The adapter-registration failure path used to release the channels via its err_dma label; that release was dropped when the probe tail was restructured into geni_i2c_init(). Release the channels on the adapter-registration failure path, mirroring geni_i2c_remove(). Fixes: d8d3bb127ad1 ("i2c: qcom-geni: Isolate serial engine setup") Cc: stable@vger.kernel.org Signed-off-by: Shengzhuo Wei <me@cherr.cc> Assisted-by: GLM:5.3 --- drivers/i2c/busses/i2c-qcom-geni.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)