From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c06::243; helo=mail-io0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x243.google.com (mail-io0-x243.google.com [IPv6:2607:f8b0:4001:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BB618210C27B3 for ; Thu, 26 Jul 2018 08:52:12 -0700 (PDT) Received: by mail-io0-x243.google.com with SMTP id w11-v6so1742546iob.2 for ; Thu, 26 Jul 2018 08:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/+lQoAy68PyKpE+m8dqrb8wy1LMYU79VFUcLOCvPyWk=; b=cRZ9G5tz1o+o+FR1lBtDN/MmZrlgWNHTMmvm8cgKDrmOZwlqwF4uY+fUqPCXThiL0x fLXxd9rIno84cO0CGBuPvG9rbqAnD4QBTla9p9Bve829/AmRHCHVjSMd5o+P1+E9YAVc NJDavjC1s7OY7iKp2XvquNiZ7SmRw/96QLxs8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/+lQoAy68PyKpE+m8dqrb8wy1LMYU79VFUcLOCvPyWk=; b=C52KyIHpwXajC5/Qp16zfcQoBl6Lp9dBZqoTOYMzAqp4ED92BKqiz/vdeYDY0UEX/w ncl+937/lteDfDtY/XSDwJTzCNJ1qcm/H8lwspIPPfNwtga/YPhMWKpkC8CcWmOu/T5t TZF6rfz+GPrD5IYH+mS3T4egakcoq/1y0x1YZRLOgLTfjpBrMwntTYStwoFXEdFytsqW /ZsjZKv4h6n7tmPjC/dwqE98Q9njaNsDbXq4aLhN99hcpALHBF+ZCp3GqYD/xKYVPTex LL+ZSbaXBZ/6uQkRiDXCBpPqNZ6X44kYDmBgvObd/Px5rWg1T0yREPXf04kmvc8Rq0T8 tutQ== X-Gm-Message-State: AOUpUlGfTPalpFwANCdmrgo12KDjTVl4uZjpO18GF1h+uCQsZ6lybj6A s66jNXIFxN76J+nrflbrz9LWW/xVcu7J1tNgaY9i3g== X-Google-Smtp-Source: AAOMgpfkCz76XHXElBeN6+QPFXtENEb5wNrt0QaMd935k2t8Xp6GgCnWcoF9vcMjNz1lMKnRSAK0bJEL1qZFhE5096c= X-Received: by 2002:a6b:5208:: with SMTP id g8-v6mr2172152iob.60.1532620331722; Thu, 26 Jul 2018 08:52:11 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Thu, 26 Jul 2018 08:52:11 -0700 (PDT) In-Reply-To: <3f19ff149bc5e3fce4f0d868de07ddb95c123d70.1532547558.git.vladimir.olovyannikov@broadcom.com> References: <3f19ff149bc5e3fce4f0d868de07ddb95c123d70.1532547558.git.vladimir.olovyannikov@broadcom.com> From: Ard Biesheuvel Date: Thu, 26 Jul 2018 17:52:11 +0200 Message-ID: To: Vladimir Olovyannikov , "Zeng, Star" , Eric Dong Cc: "edk2-devel@lists.01.org" Subject: Re: [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jul 2018 15:52:13 -0000 Content-Type: text/plain; charset="UTF-8" (add maintainers) On 25 July 2018 at 21:47, Vladimir Olovyannikov wrote: > FvSimpleFileSystem on read always allocates a FileBuffer, and never frees > it. This causes memory leaks. It is especially bad for reading scripts > line-by-line. In some cases memory leak can exceed 1GB. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Vladimir Olovyannikiov > --- > .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c > index 746f2ced708a..fde208594737 100644 > --- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c > +++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c > @@ -704,6 +704,7 @@ FvSimpleFileSystemRead ( > > Status = FvFsReadFile (File->Instance->FvProtocol, File->FvFileInfo, &FileSize, &FileBuffer); > if (EFI_ERROR (Status)) { > + FreePool (FileBuffer); > return EFI_DEVICE_ERROR; > } > > @@ -714,6 +715,8 @@ FvSimpleFileSystemRead ( > CopyMem (Buffer, (UINT8*)FileBuffer + File->Position, *BufferSize); > File->Position += *BufferSize; > > + FreePool (FileBuffer); > + > return EFI_SUCCESS; > } > } > -- > 2.18.0 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel