From nobody Mon Feb 9 20:31:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625759206232208.68303903411095; Thu, 8 Jul 2021 08:46:46 -0700 (PDT) Received: from localhost ([::1]:53896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1WEf-0000OS-2U for importer@patchew.org; Thu, 08 Jul 2021 11:46:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1VnF-0001CN-Sm for qemu-devel@nongnu.org; Thu, 08 Jul 2021 11:18:25 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:46695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1VnB-0008L5-0K for qemu-devel@nongnu.org; Thu, 08 Jul 2021 11:18:22 -0400 Received: by mail-ej1-x62c.google.com with SMTP id c17so10206221ejk.13 for ; Thu, 08 Jul 2021 08:18:20 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id ak16sm1103694ejc.17.2021.07.08.08.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 08:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D1LwxSKpvmQHORK5d6Lk9IDrh5/OjUa/lWWSxJEsvEE=; b=Mupqm+KXukD3LDvI59Luc5GD1lK7CGNJwVK/VqXTQuE41UpiK/aNH77eMdZAmwFdzu fTyCN6be0Z1CaOE9dp/OI1dF/wWr5byU63D81DROQFoDtTpTwJtVF2wVaCS5jtbkp92Y Cq3POiAc3e1YyY0FY4yprPlLv7fQ+YsioMKPnhflr5EZFrkf6d3AtQN7PKwqjBTGaMxO kcirWVjtlmc04nQ271xxqs/XcFTkEGp276kHXFvUCZFLcA8gci/4A+qLPBoAfW/XC3SV VhwV62jT/rWFZeLJruevwYJyLbD8QPyJUNN4Q0afiHlrxi9cu5SN1gahePAHqtKfWBm/ ucLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=D1LwxSKpvmQHORK5d6Lk9IDrh5/OjUa/lWWSxJEsvEE=; b=JjedJYmmQkoyBUjWZyFIKmDX98GVx7J29FqNGIuF4KXETyFMTroEJZsF7pcCJUVv8b wEzAvzw9WAWrhWDSpWUZROc9eJ8T1i1jF90LlRtDCIoV2X4USzUg7QfA+1A44EIfVRiU TueawmiBUp+Y5HD1DEwQ6Y6FreZz/Ai4Ok0ZsoSrBO1K40ZAVeam3tjHNNWU2dmeBHD6 wLR+jFhibkhKXLRu84vrR8tvNXC6FF6O+mexeQ0sKdztwZ+q+xU/QCErdI05fgRkOORt NG2tfB5vW8PA7VYQF5KiCStj1NRaqW4XLfszSx365pT0fWy6OqlV9pBVfNerljCKhiGe yitw== X-Gm-Message-State: AOAM530ZjKPPtHT4lTBsRtOGrbkpsAWT/czH+7ha27iGN7bdNnShXAiz buWxFVnZrKVCmSm1iCl1t646Pb0rWtE= X-Google-Smtp-Source: ABdhPJxWzR99hSorN0jVzQXWR/lpVAUPnF0yceo8eKQhklVgiazyvo9ZBds4lMaWBbJocVhrDbDR5g== X-Received: by 2002:a17:906:58cc:: with SMTP id e12mr31439808ejs.279.1625757499383; Thu, 08 Jul 2021 08:18:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 42/48] vl: fix leak of qdict_crumple return value Date: Thu, 8 Jul 2021 17:17:42 +0200 Message-Id: <20210708151748.408754-43-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210708151748.408754-1-pbonzini@redhat.com> References: <20210708151748.408754-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62c.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625759208277100001 Content-Type: text/plain; charset="utf-8" Coverity reports that qemu_parse_config_group is returning without unrefing the "crumpled" dictionary in case its top level item is a list. But actually the contract with qemu_record_config_group is the same as for qemu_parse_config_group itself: if those function need to stash the dictionary they get, they have to take a reference themselves (currently this is never the case for either function). Therefore, just add an unconditional qobject_unref(crumpled) to qemu_parse_config_group. Reported-by: Peter Maydell Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 2004d57108..4df1496101 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2193,12 +2193,17 @@ static void qemu_parse_config_group(const char *gro= up, QDict *qdict, if (!crumpled) { return; } - if (qobject_type(crumpled) !=3D QTYPE_QDICT) { - assert(qobject_type(crumpled) =3D=3D QTYPE_QLIST); + switch (qobject_type(crumpled)) { + case QTYPE_QDICT: + qemu_record_config_group(group, qobject_to(QDict, crumpled), false= , errp); + break; + case QTYPE_QLIST: error_setg(errp, "Lists cannot be at top level of a configuration = section"); - return; + break; + default: + g_assert_not_reached(); } - qemu_record_config_group(group, qobject_to(QDict, crumpled), false, er= rp); + qobject_unref(crumpled); } =20 static void qemu_read_default_config_file(Error **errp) --=20 2.31.1