All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 1/4] sata: ahsata: Fix resource leak
Date: Mon, 4 May 2020 08:17:47 -0600	[thread overview]
Message-ID: <CAPnjgZ03CetFHNELs-igYgQr1cXneyScU3a-JUD7oMjuSM2uVg@mail.gmail.com> (raw)
In-Reply-To: <20200503142703.14903-1-peng.fan@nxp.com>

On Sun, 3 May 2020 at 08:04, Peng Fan <peng.fan@nxp.com> wrote:
>
> From: Ye Li <ye.li@nxp.com>
>
> Fix coverity issue CID 3606684: Resource leak (RESOURCE_LEAK)
> leaked_storage: Variable uc_priv going out of scope leaks the storage it points to
>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/ata/dwc_ahsata.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
> index c2e28fe518..a775214792 100644
> --- a/drivers/ata/dwc_ahsata.c
> +++ b/drivers/ata/dwc_ahsata.c
> @@ -847,6 +847,9 @@ static int ahci_init_one(int pdev)
>         struct ahci_uc_priv *uc_priv = NULL;
>
>         uc_priv = malloc(sizeof(struct ahci_uc_priv));
> +       if (!uc_priv)
> +               return -ENOMEM;
> +
>         memset(uc_priv, 0, sizeof(struct ahci_uc_priv));
>         uc_priv->dev = pdev;
>
> @@ -871,6 +874,8 @@ static int ahci_init_one(int pdev)
>         return 0;
>
>  err_out:
> +       if (uc_priv)
> +               free(uc_priv);

Seems like you can avoid the if() since it is always allocated at this point?

The migration date for SATA was over 6 months ago so really this code
should not be used at this point.

Regards,
Simon

  parent reply	other threads:[~2020-05-04 14:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 14:27 [PATCH 1/4] sata: ahsata: Fix resource leak Peng Fan
2020-05-03 14:27 ` [PATCH 2/4] sata: ahsata: Fix wrong operand for checking SERR DIAG_X Peng Fan
2020-05-04 14:17   ` Simon Glass
2020-05-08 22:59   ` Tom Rini
2020-05-03 14:27 ` [PATCH 3/4] sata: dwc_ahsata: Fix incorrect free Peng Fan
2020-05-04 14:17   ` Simon Glass
2020-05-08 22:59   ` Tom Rini
2020-05-03 14:27 ` [PATCH 4/4] sata: dwc_ahsata: Fix memory issue in reset_sata Peng Fan
2020-05-08 22:59   ` Tom Rini
2020-05-04 14:17 ` Simon Glass [this message]
2020-05-04 14:28   ` [PATCH 1/4] sata: ahsata: Fix resource leak Peng Fan
2020-05-08 22:59 ` Tom Rini

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=CAPnjgZ03CetFHNELs-igYgQr1cXneyScU3a-JUD7oMjuSM2uVg@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.