lkml.org 
[lkml]   [2020]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 5.4 136/266] ASoC: ti: omap-mcbsp: Fix an error handling path in 'asoc_mcbsp_probe()'
    Date
    From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

    [ Upstream commit 03990fd58d2b7c8f7d53e514ba9b8749fac260f9 ]

    If an error occurs after the call to 'omap_mcbsp_init()', the reference to
    'mcbsp->fclk' must be decremented, as already done in the remove function.

    This can be achieved easily by using the devm_ variant of 'clk_get()'
    when the reference is taken in 'omap_mcbsp_init()'

    This fixes the leak in the probe and has the side effect to simplify both
    the error handling path of 'omap_mcbsp_init()' and the remove function.

    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Acked-by: Peter Ujfalusi <peter.ujflausi@ti.com>
    Link: https://lore.kernel.org/r/20200512134325.252073-1-christophe.jaillet@wanadoo.fr
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    sound/soc/ti/omap-mcbsp.c | 8 ++------
    1 file changed, 2 insertions(+), 6 deletions(-)

    diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
    index 26b503bbdb5f..3273b317fa3b 100644
    --- a/sound/soc/ti/omap-mcbsp.c
    +++ b/sound/soc/ti/omap-mcbsp.c
    @@ -686,7 +686,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
    mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp,
    SNDRV_PCM_STREAM_CAPTURE);

    - mcbsp->fclk = clk_get(&pdev->dev, "fck");
    + mcbsp->fclk = devm_clk_get(&pdev->dev, "fck");
    if (IS_ERR(mcbsp->fclk)) {
    ret = PTR_ERR(mcbsp->fclk);
    dev_err(mcbsp->dev, "unable to get fck: %d\n", ret);
    @@ -711,7 +711,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
    if (ret) {
    dev_err(mcbsp->dev,
    "Unable to create additional controls\n");
    - goto err_thres;
    + return ret;
    }
    }

    @@ -724,8 +724,6 @@ static int omap_mcbsp_init(struct platform_device *pdev)
    err_st:
    if (mcbsp->pdata->buffer_size)
    sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
    -err_thres:
    - clk_put(mcbsp->fclk);
    return ret;
    }

    @@ -1442,8 +1440,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev)

    omap_mcbsp_st_cleanup(pdev);

    - clk_put(mcbsp->fclk);
    -
    return 0;
    }

    --
    2.25.1
    \
     
     \ /
      Last update: 2020-06-18 04:19    [W:4.183 / U:0.148 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site