linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libkmod-config: fix a memory leak when kmod_list_append() fails
       [not found] <CGME20210409094133epcas1p2cfb973c9ea1065ffbb018e98f9a60b10@epcas1p2.samsung.com>
@ 2021-04-09  9:44 ` Seung-Woo Kim
  2021-04-09 15:13   ` Lucas De Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Seung-Woo Kim @ 2021-04-09  9:44 UTC (permalink / raw)
  To: linux-modules, lucas.de.marchi; +Cc: sw0312.kim, sungguk.na

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libkmod-config: fix a memory leak when kmod_list_append() fails
  2021-04-09  9:44 ` [PATCH] libkmod-config: fix a memory leak when kmod_list_append() fails Seung-Woo Kim
@ 2021-04-09 15:13   ` Lucas De Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Lucas De Marchi @ 2021-04-09 15:13 UTC (permalink / raw)
  To: Seung-Woo Kim; +Cc: linux-modules, sungguk.na

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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-09 15:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210409094133epcas1p2cfb973c9ea1065ffbb018e98f9a60b10@epcas1p2.samsung.com>
2021-04-09  9:44 ` [PATCH] libkmod-config: fix a memory leak when kmod_list_append() fails Seung-Woo Kim
2021-04-09 15:13   ` Lucas De Marchi

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox