Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp211830pxb; Sat, 20 Feb 2021 00:49:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzC4TudEGHj1RC7z49vEMyrjskP7KnuKde7rT11YQh4NW5xZ28uQNGuCrryCCViT17CVKdl X-Received: by 2002:a17:906:4159:: with SMTP id l25mr5152409ejk.422.1613810979341; Sat, 20 Feb 2021 00:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613810979; cv=none; d=google.com; s=arc-20160816; b=u2XuMfEkRwx2QSU0hmoKsT481RCp0KpXFYGOb6NeAzNqyMUeJwuaZ+VCdsxlbzRSu7 LuKOu7Lrc0vqngPEr3RQWl+mrVZ5jkvHlutKsqEFN7CI+749WQw/KBqdIj//YoNdGvs6 yp3a7+AYbLD0iy6y1ejMeSiTXT3cHoiLmz6hgH3yi5x3gtN0dfWBBABSchwVl/3Rob4H kxnWWGCq/FrLpWLwCQb8NbEraM84AyF0uyR0XTLkchKnjhdYjbZUaniMScuEc/enPCze Mi+xBaJ63tAYBxgiQYaTNIh5sG8HHz0E1OJvWoUHNsj9KdQAZoJw1Sn+ISNBEdjGfXtG W+RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:cc:to; bh=37b8z1LbXwUA/lqogMT53JZGBaxpdWuedlCCBMSZc1M=; b=hrm2iu2wDVLtUBVTgtEMGjtvMNjNQCb/6Lm2sELm8wEr0V0Z16l+NPZDzHh23+/LPl QYVZnFQ+T8Eqv83hxjRhG5LMdZ/VupQ9Nm77PMAjd+QzIE0xD9y/hodl1yWxYDx/XZOX fX7Bv4YYP08USD02mTev6cRk4DRnXxQ8rJwgmt5XYbMKCCbMvWmJ0mGOE6C4/cnKl+Ep J+/xULJpPLqs2EUbXFjUpyM1NyhrYpvpv9XNPhWSM1bWIPx2r5LkqU+Gp/JqOm2jpg3J tZmVTYPbJzNMvTvrXv86PQRHEPiOuIRRW/VjW3Qbz5EJuF66A8faT1cg/YWlcXye+eze P3JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do5si7205144ejc.441.2021.02.20.00.49.09; Sat, 20 Feb 2021 00:49:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbhBTIm2 (ORCPT + 99 others); Sat, 20 Feb 2021 03:42:28 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12196 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbhBTImX (ORCPT ); Sat, 20 Feb 2021 03:42:23 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DjMM35CqVzlMjV; Sat, 20 Feb 2021 16:39:43 +0800 (CST) Received: from [127.0.0.1] (10.174.176.117) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Sat, 20 Feb 2021 16:41:29 +0800 To: Ext4 Developers List , "Theodore Y. Ts'o" CC: harshad shirwadkar , linfeilong , lihaotian , , "lijinlin (A)" From: Zhiqiang Liu Subject: [PATCH] debugfs: fix memory leak problem in read_list() Message-ID: Date: Sat, 20 Feb 2021 16:41:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.117] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 Signed-off-by: linfeilong --- 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