Re: [Patch V1] imx: i2c: fix i2c resource leak with dma transfer
On Wed, Dec 02, 2015 at 05:52:38PM +0800, Gao Pan wrote: > In i2c_imx_dma_xfer(), when dmaengine_prep_slave_single() returns > NULL, the context goto label err_desc and then return. However, > the memory allocated by dmaengine_prep_slave_single() has not been > freed yet, which leads to resource leak. dmaengine_prep_slave_single() still owns allocated memory although it returns NULL? Isn't this a bug? > > (reported by coverity check) > > Signed-off-by: Gao Pan> Signed-off-by: Fugang Duan > --- > drivers/i2c/busses/i2c-imx.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c > index 0ab8424..6dcfff5 100644 > --- a/drivers/i2c/busses/i2c-imx.c > +++ b/drivers/i2c/busses/i2c-imx.c > @@ -397,6 +397,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct > *i2c_imx, > > err_submit: > err_desc: > + dmaengine_terminate_all(dma->chan_using); > dma_unmap_single(chan_dev, dma->dma_buf, > dma->dma_len, dma->dma_data_dir); > err_map: > -- > 1.9.1 > signature.asc Description: Digital signature
[Patch V1] imx: i2c: fix i2c resource leak with dma transfer
In i2c_imx_dma_xfer(), when dmaengine_prep_slave_single() returns NULL, the context goto label err_desc and then return. However, the memory allocated by dmaengine_prep_slave_single() has not been freed yet, which leads to resource leak. (reported by coverity check) Signed-off-by: Gao PanSigned-off-by: Fugang Duan --- drivers/i2c/busses/i2c-imx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 0ab8424..6dcfff5 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -397,6 +397,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx, err_submit: err_desc: + dmaengine_terminate_all(dma->chan_using); dma_unmap_single(chan_dev, dma->dma_buf, dma->dma_len, dma->dma_data_dir); err_map: -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html