linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.de.marchi@gmail.com>
To: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: linux-modules <linux-modules@vger.kernel.org>, sungguk.na@samsung.com
Subject: Re: [PATCH] libkmod-config: fix a memory leak when kmod_list_append() fails
Date: Fri, 9 Apr 2021 08:13:29 -0700	[thread overview]
Message-ID: <CAKi4VAL2q0TUcR3ZFjJiwA=7xmBmJ1VcwSkY_HYW16WFmxv5aA@mail.gmail.com> (raw)
In-Reply-To: <20210409094423.966-1-sw0312.kim@samsung.com>

On Fri, Apr 9, 2021 at 2:41 AM Seung-Woo Kim <sw0312.kim@samsung.com> wrote:
>
> From kmod_config_new(), when kmod_list_append() fails,
> fix not list-appended kmod_config_path leak.
>
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>

Applied, thanks
Lucas De Marchi

> ---
>  libkmod/libkmod-config.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
> index 4fdd40f86dea..e83621b34157 100644
> --- a/libkmod/libkmod-config.c
> +++ b/libkmod/libkmod-config.c
> @@ -909,8 +909,10 @@ int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **p_config,
>                 memcpy(cf->path, path, pathlen);
>
>                 tmp = kmod_list_append(path_list, cf);
> -               if (tmp == NULL)
> +               if (tmp == NULL) {
> +                       free(cf);
>                         goto oom;
> +               }
>                 path_list = tmp;
>         }
>
> --
> 2.19.2
>

      reply	other threads:[~2021-04-09 15:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210409094133epcas1p2cfb973c9ea1065ffbb018e98f9a60b10@epcas1p2.samsung.com>
2021-04-09  9:44 ` Seung-Woo Kim
2021-04-09 15:13   ` Lucas De Marchi [this message]

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='CAKi4VAL2q0TUcR3ZFjJiwA=7xmBmJ1VcwSkY_HYW16WFmxv5aA@mail.gmail.com' \
    --to=lucas.de.marchi@gmail.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=sungguk.na@samsung.com \
    --cc=sw0312.kim@samsung.com \
    --subject='Re: [PATCH] libkmod-config: fix a memory leak when kmod_list_append() fails' \
    /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

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).