mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fsi: master-ast-cf: Fix memory leak
Date: Thu, 26 Jul 2018 09:45:27 +1000	[thread overview]
Message-ID: <8fb34eab67d3c594fd49690a25c5c8072105417d.camel@kernel.crashing.org> (raw)
In-Reply-To: <20180725133832.GA20837@embeddedor.com>

On Wed, 2018-07-25 at 08:38 -0500, Gustavo A. R. Silva wrote:
> In case memory resources for *fw* were allocated, release them
> before return.
> 
> Addresses-Coverity-ID: 1472044 ("Resource leak")
> Fixes: 6a794a27daca ("fsi: master-ast-cf: Add new FSI master using Aspeed ColdFire")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Thanks Gustavo !

I'll apply before I send my next pull request to Greg !

Cheers,
Ben.

> ---
>  drivers/fsi/fsi-master-ast-cf.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
> index c4a3557..e39a4630 100644
> --- a/drivers/fsi/fsi-master-ast-cf.c
> +++ b/drivers/fsi/fsi-master-ast-cf.c
> @@ -861,7 +861,8 @@ static int load_copro_firmware(struct fsi_master_acf *master)
>  	if (sig != wanted_sig) {
>  		dev_err(master->dev, "Failed to locate image sig %04x in FW blob\n",
>  			wanted_sig);
> -		return -ENODEV;
> +		rc = -ENODEV;
> +		goto release_fw;
>  	}
>  	if (size > master->cf_mem_size) {
>  		dev_err(master->dev, "FW size (%zd) bigger than memory reserve (%zd)\n",
> @@ -870,8 +871,9 @@ static int load_copro_firmware(struct fsi_master_acf *master)
>  	} else {
>  		memcpy_toio(master->cf_mem, data, size);
>  	}
> -	release_firmware(fw);
>  
> +release_fw:
> +	release_firmware(fw);
>  	return rc;
>  }
>  


  reply	other threads:[~2018-07-25 23:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 13:38 Gustavo A. R. Silva
2018-07-25 23:45 ` Benjamin Herrenschmidt [this message]
2018-07-26  0:26   ` Gustavo A. R. Silva

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=8fb34eab67d3c594fd49690a25c5c8072105417d.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=gustavo@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®