public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] debugfs: fix memory leak problem in read_list()
@ 2021-02-20  8:41 Zhiqiang Liu
  2021-02-25  1:39 ` Zhiqiang Liu
  2021-02-25 15:51 ` harshad shirwadkar
  0 siblings, 2 replies; 6+ messages in thread
From: Zhiqiang Liu @ 2021-02-20  8:41 UTC (permalink / raw)
  To: Ext4 Developers List, Theodore Y. Ts'o
  Cc: harshad shirwadkar, linfeilong, lihaotian, liuzhiqiang26,
	lijinlin (A)


In read_list func, if strtoull() fails in while loop,
we will return the error code directly. Then, memory of
variable lst will be leaked without setting to *list.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: linfeilong <linfeilong@huawei.com>
---
 debugfs/util.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/debugfs/util.c b/debugfs/util.c
index be6b550e..9e880548 100644
--- a/debugfs/util.c
+++ b/debugfs/util.c
@@ -530,12 +530,16 @@ errcode_t read_list(char *str, blk64_t **list, size_t *len)

 		errno = 0;
 		y = x = strtoull(tok, &e, 0);
-		if (errno)
-			return errno;
+		if (errno) {
+			retval = errno;
+			break;
+		}
 		if (*e == '-') {
 			y = strtoull(e + 1, NULL, 0);
-			if (errno)
-				return errno;
+			if (errno) {
+				retval = errno;
+				break;
+			}
 		} else if (*e != 0) {
 			retval = EINVAL;
 			break;
-- 
2.19.1



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

end of thread, other threads:[~2021-02-26  1:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-20  8:41 [PATCH] debugfs: fix memory leak problem in read_list() Zhiqiang Liu
2021-02-25  1:39 ` Zhiqiang Liu
2021-02-25 15:51 ` harshad shirwadkar
2021-02-25 17:02   ` Theodore Ts'o
2021-02-25 17:13     ` harshad shirwadkar
2021-02-26  1:18     ` Zhiqiang Liu

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