From patchwork Tue Jan 15 13:42:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Czerner X-Patchwork-Id: 1025181 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43fBMy6fN6z9sBQ for ; Wed, 16 Jan 2019 00:42:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728728AbfAONmG (ORCPT ); Tue, 15 Jan 2019 08:42:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54014 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728560AbfAONmG (ORCPT ); Tue, 15 Jan 2019 08:42:06 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2EA3881DF3 for ; Tue, 15 Jan 2019 13:42:06 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.205.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C3BB60606 for ; Tue, 15 Jan 2019 13:42:05 +0000 (UTC) From: Lukas Czerner To: linux-ext4@vger.kernel.org Subject: [PATCH 1/2] e2freefrag: fix memory leak in scan_online() Date: Tue, 15 Jan 2019 14:42:02 +0100 Message-Id: <20190115134203.11448-1-lczerner@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 15 Jan 2019 13:42:06 +0000 (UTC) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Signed-off-by: Lukas Czerner --- misc/e2freefrag.c | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c index f7fede54..935ae225 100644 --- a/misc/e2freefrag.c +++ b/misc/e2freefrag.c @@ -236,6 +236,7 @@ static int scan_online(ext2_filsys fs, struct chunk_info *info, fsmap_advance(fsmap); } + free(fsmap); return 1; } #else From patchwork Tue Jan 15 13:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Czerner X-Patchwork-Id: 1025182 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43fBN00pWlz9sCs for ; Wed, 16 Jan 2019 00:42:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729245AbfAONmH (ORCPT ); Tue, 15 Jan 2019 08:42:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20369 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728560AbfAONmH (ORCPT ); Tue, 15 Jan 2019 08:42:07 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0FB24A6DE0 for ; Tue, 15 Jan 2019 13:42:07 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.205.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 753BC608FA for ; Tue, 15 Jan 2019 13:42:06 +0000 (UTC) From: Lukas Czerner To: linux-ext4@vger.kernel.org Subject: [PATCH 2/2] e2fsprogs: fix potential memory leak in path_append() Date: Tue, 15 Jan 2019 14:42:03 +0100 Message-Id: <20190115134203.11448-2-lczerner@redhat.com> In-Reply-To: <20190115134203.11448-1-lczerner@redhat.com> References: <20190115134203.11448-1-lczerner@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 15 Jan 2019 13:42:07 +0000 (UTC) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If realloc() fails in path_append() we will lose a memory pointed to by target->path. Fix it. Signed-off-by: Lukas Czerner --- misc/create_inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/create_inode.c b/misc/create_inode.c index 05aa6363..cedbba52 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -704,10 +704,12 @@ struct file_info { static errcode_t path_append(struct file_info *target, const char *file) { if (strlen(file) + target->path_len + 1 > target->path_max_len) { + void *p; target->path_max_len *= 2; - target->path = realloc(target->path, target->path_max_len); - if (!target->path) + p = realloc(target->path, target->path_max_len); + if (p == NULL) return EXT2_ET_NO_MEMORY; + target->path = p; } target->path_len += sprintf(target->path + target->path_len, "/%s", file);