linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Fabio Estevam <festevam@gmail.com>
Cc: k.debski@samsung.com, m.chehab@samsung.com,
	kernel@pengutronix.de, linux-media@vger.kernel.org,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: Re: [PATCH v3 2/3] [media] coda: Check the return value from clk_prepare_enable()
Date: Tue, 23 Jul 2013 15:06:54 +0200	[thread overview]
Message-ID: <1374584814.4041.8.camel@pizza.hi.pengutronix.de> (raw)
In-Reply-To: <1374543502-22678-2-git-send-email-festevam@gmail.com>

Hi Fabio,

Am Montag, den 22.07.2013, 22:38 -0300 schrieb Fabio Estevam:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> clk_prepare_enable() may fail, so let's check its return value and propagate it
> in the case of error.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> - Changes since v2:
> - Release the previously acquired resources
> Changes since v1:
> - Add missing 'if'
> 
>  drivers/media/platform/coda.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
> index ea16c20..5f15aaa 100644
> --- a/drivers/media/platform/coda.c
> +++ b/drivers/media/platform/coda.c
> @@ -1561,14 +1561,27 @@ static int coda_open(struct file *file)
>  	list_add(&ctx->list, &dev->instances);
>  	coda_unlock(ctx);
>  
> -	clk_prepare_enable(dev->clk_per);
> -	clk_prepare_enable(dev->clk_ahb);
> +	ret = clk_prepare_enable(dev->clk_per);
> +	if (ret)
> +		goto err_clk_per;
> +
> +	ret = clk_prepare_enable(dev->clk_ahb);
> +	if (ret)
> +		goto err_clk_ahb;
>  
>  	v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "Created instance %d (%p)\n",
>  		 ctx->idx, ctx);
>  
>  	return 0;
>  
> +err_clk_ahb:
> +	clk_disable_unprepare(dev->clk_per);
> +err_clk_per:
> +	coda_lock(ctx);
> +	list_del(&ctx->list);
> +	coda_unlock(ctx);
> +	dma_free_coherent(&dev->plat_dev->dev, CODA_PARA_BUF_SIZE,
> +			  ctx->parabuf.vaddr, ctx->parabuf.paddr);
>  err_dma_alloc:
>  	v4l2_ctrl_handler_free(&ctx->ctrls);
>  err_ctrls_setup:

I still think the list_add() should be moved after the last possible
error case and the lock/list_del/unlock should be removed from the error
path.

regards
Philipp


  reply	other threads:[~2013-07-23 13:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23  1:38 [PATCH v3 1/3] [media] coda: Fix error paths Fabio Estevam
2013-07-23  1:38 ` [PATCH v3 2/3] [media] coda: Check the return value from clk_prepare_enable() Fabio Estevam
2013-07-23 13:06   ` Philipp Zabel [this message]
2013-07-23  1:38 ` [PATCH v3 3/3] [media] coda: No need to check the return value of platform_get_resource() Fabio Estevam
2013-07-23 13:03 ` [PATCH v3 1/3] [media] coda: Fix error paths Philipp Zabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374584814.4041.8.camel@pizza.hi.pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=fabio.estevam@freescale.com \
    --cc=festevam@gmail.com \
    --cc=k.debski@samsung.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).