Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29B3BC433F5 for ; Mon, 20 Sep 2021 12:58:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD8B36109D for ; Mon, 20 Sep 2021 12:58:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AD8B36109D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSIrz-0005RA-TR for qemu-devel@archiver.kernel.org; Mon, 20 Sep 2021 08:58:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSIr5-0004lM-Fg for qemu-devel@nongnu.org; Mon, 20 Sep 2021 08:57:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSIr1-0007GG-S6 for qemu-devel@nongnu.org; Mon, 20 Sep 2021 08:57:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632142621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n079083B6k5FNu5HBCdqB/lUt70q20Xo/zWiaBpDkkI=; b=PPGHCnu7Rpgza+KfKjyaIO7eSh1xpH6iupaY92BIPoHRfrnTebVyd66g6vuY3/6C4neZHz xfhdPJeH38QaS2b76qIAy2Fs/Me2TmjlwKrIhvJkNys+YUYDh+HSKgqgrlRJGyjt1yctJy npI1Bh1An7kFzOzxuL8y9wLEgQgT1IQ= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-RxoLxdKyPDeDpgULdHUUVw-1; Mon, 20 Sep 2021 08:56:58 -0400 X-MC-Unique: RxoLxdKyPDeDpgULdHUUVw-1 Received: by mail-ed1-f70.google.com with SMTP id o23-20020a509b17000000b003d739e2931dso13865444edi.4 for ; Mon, 20 Sep 2021 05:56:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=n079083B6k5FNu5HBCdqB/lUt70q20Xo/zWiaBpDkkI=; b=FFNzORge8v+pwP5pMXo3Hhj+5hF+CYtnsvT9tdo/kDA+L59yrVBB45LYzA2FaRlKAw QLh4FOYcH2p6Wfw/0yrSeTzTWY+Msh2mCLwyid4khkRIH/2oRtSKFhyTDViayDI3QSbI Sui7zj94TzpVIXgIvJh77WaumJSUIFS5pxaR59odwgIaVPJI9X6OjCcpB1qJFOZmhp2p S8anhJAueQVXP05LP9ZArtb3iVDM1TdrSAlIu63T5BHp1OxRTL9zWqnigbrjj/ryIoiy TS9ieuJ9gCMUsFnBPKIxzhHZyXbrNTsibKMw+ZSgq85grJHVPFOhX4Xwpz/xuTPTiogA x6/Q== X-Gm-Message-State: AOAM530MvM7n6oYEBsblibdU+FfzQa5vAhNYjPT880JmGHib7T3QvQ7/ DJVkfVqlFGRg7b/wzAHgY3g/dGkLhX+jMm3XEREs9sZQKFq0LKLpK+yq1yQ0W6TpQtMxdmYFcD1 wTlEYsKqMedmGJIM= X-Received: by 2002:a17:906:2bc7:: with SMTP id n7mr27520372ejg.238.1632142616873; Mon, 20 Sep 2021 05:56:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvn1/7fogKUt30b7w+EvXjgGv95oe1Td7lq83b3v5GuwlARDx2XBqgzE7+5vGN9q6Na69xfQ== X-Received: by 2002:a17:906:2bc7:: with SMTP id n7mr27520356ejg.238.1632142616666; Mon, 20 Sep 2021 05:56:56 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id y4sm6097299ejr.101.2021.09.20.05.56.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Sep 2021 05:56:55 -0700 (PDT) Subject: Re: [PATCH] target/i386: Fix memory leak in sev_read_file_base64() To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , Peter Maydell , qemu-devel@nongnu.org References: <20210820165650.2839-1-peter.maydell@linaro.org> From: Paolo Bonzini Message-ID: Date: Mon, 20 Sep 2021 14:56:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.475, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pan Nengyuan , Li Qiang , Brijesh Singh Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 20/08/21 19:05, Philippe Mathieu-Daudé wrote: > On 8/20/21 6:56 PM, Peter Maydell wrote: >> In sev_read_file_base64() we call g_file_get_contents(), which >> allocates memory for the file contents. We then base64-decode the >> contents (which allocates another buffer for the decoded data), but >> forgot to free the memory for the original file data. >> >> Use g_autofree to ensure that the file data is freed. >> >> Fixes: Coverity CID 1459997 >> Signed-off-by: Peter Maydell >> --- >> Tested with 'make/make check' only... >> >> target/i386/sev.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) > > Reviewed-by: Philippe Mathieu-Daudé > Queued, thanks. Paolo