From patchwork Wed Jun 7 17:50:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 103306 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2059611qgd; Wed, 7 Jun 2017 10:54:02 -0700 (PDT) X-Received: by 10.55.84.68 with SMTP id i65mr8951090qkb.161.1496858042825; Wed, 07 Jun 2017 10:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496858042; cv=none; d=google.com; s=arc-20160816; b=uCNNptnsFTHDuzo1PZQZJIomZ8uB1lFCDrDOs1v1/GfI/OlwyqJKBgXv2NGQSAh2Mr /lGA1FrzCW9DnyZB+nUeS9t/pGGS4BfUajQmiybAT1semaJwgrAvhafLmtgIz8ryYrxQ OQucS8PSCJLh1I4s/er0gCuDcasI9ynajbgjpwzsosj8i3x5p2vmWKr06meJhkhQvaVu yrTnC333nideBSIJFgpQrHscqijDy+nNNbBnnzNbsbpjz9Ekueuz41OYU6EoL9YIIwKn HxoT4XapoqwFskxvUQnhJTH5j5ZD936c6ty8sytExdLjw08EQ+CXB7kKC9JYCWX6/IM3 qT5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-filter:dmarc-filter :arc-authentication-results; bh=vZftr9T1P5hy0YHiVw0So+espv+tZp4CAsLdPco8N3Y=; b=rvcpEduZtCMhBYkL1h54K104KO2j+NFg3XJ98NABxXc8eDRC92rBZvzdehDtX4Wv7r Zsy93xJ2m6AUsRqsLIpZizz/EBTiS3dhNwjQ9OmSuCaj2B7yov2eESg9451GnHU3NsF9 N9nuJDim6ARyV8gvAb/g1WvcS0R9XoU8B4helE+R2KZWaWW344zNFJa8HVvsIX67h8cj fzOXvXv+ICz8GwApempGGapZAJaBlMIZvX5bkI/yatbbhLrykc+JSuUvmuFDOiyMPN24 w9z9AIHVQykH8++hLWFdKm1XEHuFQRutHxqMNa3HzQKP/WuXo88N8krweHY3PcYlm2xb upnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l50si2779958qta.3.2017.06.07.10.54.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 07 Jun 2017 10:54:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:45523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIf9c-0004YH-C6 for patch@linaro.org; Wed, 07 Jun 2017 13:54:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIf6L-0001zk-JO for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:50:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIf6K-0005wo-Oe for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:50:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIf6I-0005vu-Lj; Wed, 07 Jun 2017 13:50:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 975557F3EC; Wed, 7 Jun 2017 17:50:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 975557F3EC Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 975557F3EC Received: from noname.redhat.com (ovpn-117-1.ams2.redhat.com [10.36.117.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 945247E64A; Wed, 7 Jun 2017 17:50:32 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 7 Jun 2017 19:50:18 +0200 Message-Id: <1496857819-12466-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1496857819-12466-1-git-send-email-kwolf@redhat.com> References: <1496857819-12466-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 07 Jun 2017 17:50:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/8] block/qcow.c: Fix memory leak in qcow_create() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Coverity points out that the code path in qcow_create() for the magic "fat:" backing file name leaks the memory used to store the filename (CID 1307771). Free the memory before we overwrite the pointer. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Kevin Wolf --- block/qcow.c | 1 + 1 file changed, 1 insertion(+) -- 1.8.3.1 diff --git a/block/qcow.c b/block/qcow.c index 95ab123..7bd94dc 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -852,6 +852,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp) header_size += backing_filename_len; } else { /* special backing file for vvfat */ + g_free(backing_file); backing_file = NULL; } header.cluster_bits = 9; /* 512 byte cluster to avoid copying