Message ID | 20220513100541.2665467-1-yangyingliang@huawei.com |
---|---|
State | New |
Headers | show |
Series | [-next] video: fbdev: pxa3xx-gcu: release the resources correctly in pxa3xx_gcu_probe/remove() | expand |
On 5/13/22 12:05, Yang Yingliang wrote: > In pxa3xx_gcu_probe(), the sequence of error lable is wrong, it will > leads some resource leaked, so adjust the sequence to handle the error > correctly, and if pxa3xx_gcu_add_buffer() fails, pxa3xx_gcu_free_buffers() > need be called. > In pxa3xx_gcu_remove(), add missing clk_disable_unpreprare(). > > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> applied to fbdev tree. Thanks! Helge > --- > drivers/video/fbdev/pxa3xx-gcu.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c > index 350b3139c863..043cc8f9ef1c 100644 > --- a/drivers/video/fbdev/pxa3xx-gcu.c > +++ b/drivers/video/fbdev/pxa3xx-gcu.c > @@ -646,6 +646,7 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) > for (i = 0; i < 8; i++) { > ret = pxa3xx_gcu_add_buffer(dev, priv); > if (ret) { > + pxa3xx_gcu_free_buffers(dev, priv); > dev_err(dev, "failed to allocate DMA memory\n"); > goto err_disable_clk; > } > @@ -662,15 +663,15 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) > SHARED_SIZE, irq); > return 0; > > -err_free_dma: > - dma_free_coherent(dev, SHARED_SIZE, > - priv->shared, priv->shared_phys); > +err_disable_clk: > + clk_disable_unprepare(priv->clk); > > err_misc_deregister: > misc_deregister(&priv->misc_dev); > > -err_disable_clk: > - clk_disable_unprepare(priv->clk); > +err_free_dma: > + dma_free_coherent(dev, SHARED_SIZE, > + priv->shared, priv->shared_phys); > > return ret; > } > @@ -683,6 +684,7 @@ static int pxa3xx_gcu_remove(struct platform_device *pdev) > pxa3xx_gcu_wait_idle(priv); > misc_deregister(&priv->misc_dev); > dma_free_coherent(dev, SHARED_SIZE, priv->shared, priv->shared_phys); > + clk_disable_unprepare(priv->clk); > pxa3xx_gcu_free_buffers(dev, priv); > > return 0;
diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c index 350b3139c863..043cc8f9ef1c 100644 --- a/drivers/video/fbdev/pxa3xx-gcu.c +++ b/drivers/video/fbdev/pxa3xx-gcu.c @@ -646,6 +646,7 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) for (i = 0; i < 8; i++) { ret = pxa3xx_gcu_add_buffer(dev, priv); if (ret) { + pxa3xx_gcu_free_buffers(dev, priv); dev_err(dev, "failed to allocate DMA memory\n"); goto err_disable_clk; } @@ -662,15 +663,15 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) SHARED_SIZE, irq); return 0; -err_free_dma: - dma_free_coherent(dev, SHARED_SIZE, - priv->shared, priv->shared_phys); +err_disable_clk: + clk_disable_unprepare(priv->clk); err_misc_deregister: misc_deregister(&priv->misc_dev); -err_disable_clk: - clk_disable_unprepare(priv->clk); +err_free_dma: + dma_free_coherent(dev, SHARED_SIZE, + priv->shared, priv->shared_phys); return ret; } @@ -683,6 +684,7 @@ static int pxa3xx_gcu_remove(struct platform_device *pdev) pxa3xx_gcu_wait_idle(priv); misc_deregister(&priv->misc_dev); dma_free_coherent(dev, SHARED_SIZE, priv->shared, priv->shared_phys); + clk_disable_unprepare(priv->clk); pxa3xx_gcu_free_buffers(dev, priv); return 0;
In pxa3xx_gcu_probe(), the sequence of error lable is wrong, it will leads some resource leaked, so adjust the sequence to handle the error correctly, and if pxa3xx_gcu_add_buffer() fails, pxa3xx_gcu_free_buffers() need be called. In pxa3xx_gcu_remove(), add missing clk_disable_unpreprare(). Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/video/fbdev/pxa3xx-gcu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)