linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Seung-Woo Kim <sw0312.kim@samsung.com>
To: linux-modules@vger.kernel.org, lucas.de.marchi@gmail.com
Cc: sw0312.kim@samsung.com, sungguk.na@samsung.com
Subject: [PATCH] libkmod-config: fix a memory leak when kmod_list_append() fails
Date: Fri,  9 Apr 2021 18:44:23 +0900	[thread overview]
Message-ID: <20210409094423.966-1-sw0312.kim@samsung.com> (raw)
In-Reply-To: <CGME20210409094133epcas1p2cfb973c9ea1065ffbb018e98f9a60b10@epcas1p2.samsung.com>

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


       reply	other threads:[~2021-04-09  9:41 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 [this message]
2021-04-09 15:13   ` Lucas De Marchi

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=20210409094423.966-1-sw0312.kim@samsung.com \
    --to=sw0312.kim@samsung.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    --cc=sungguk.na@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).