From patchwork Wed Jan 6 03:37:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 357541 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp528802jai; Tue, 5 Jan 2021 19:39:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJypncsrf9M3aL65dO1S1WZGuBb4Ya99Bw1j6+ww+9VVQ6Ypy4gMPtXgcHRg0NCb1B+85RkK X-Received: by 2002:a25:ac1f:: with SMTP id w31mr3610459ybi.87.1609904341882; Tue, 05 Jan 2021 19:39:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609904341; cv=none; d=google.com; s=arc-20160816; b=N2f+4Hs4dpPYXejUhW1tS+xt8DzGekefNIZ/Thv2jIiD1d6mCYpaOwrgZK7b+Lb95h GPXu/Qz012laVzns1qybNYG0B/0UnkVi+d7qLk+GeyAlnUkwdgS6RSxfCdd1R4O/6mlD pHmdf/pm3Y/BJtIqv2oR7FaXMEPW10UTuB3Nc9NrejudhilansR9z7KagBlUqrYA6A+d //soCtnnkap1qBwxdBQCUmWKQ1O5zBtgYFfufV4PXC2umywflv3RViTi6sC1T731aObP em1DVYf2AC5vo3u1UeS7rLQS4xBkMQgfvnGyV1Ru4xCaYg7CsgN9xe8M1BV5u76ImPmc CSkA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GMVVvkIycYScd3/gBGc/OwP56/GL6LNBUbMegYsQStY=; b=TyKFw88fFoxb5vlsDS84qrQm3JOpYCES7ccFRoc5AUDDF544F8VNf7ygWeB+Ff/cAf GmpEYsqHdDyxbDPTOC70oD8XJvdFReV//kYrrf/FwaZrHdj5X0DRTjP89KKZ8+MWOg4E hf8f4FBZD7xqnN9b4W/k1UxFn16Oe0Ep4nYqvr6CejlIZYOPOqAkY2on28GVI3GlMmOT xLBsJI1oECVNph/1QO2y6skrvQkqRHmS5FIC6WCOWL+i5hl+W4gyVLWYGMb9DwtDjyc8 iSz3oCMutfMFeVJQlVuIP2h4d9DJmOv9nUJk3+OMTJnHQB7NwJjd2XYYtAobwFLivF/5 MGDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b="l0KD/6fU"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d130si1919653ybc.102.2021.01.05.19.39.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 19:39:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b="l0KD/6fU"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:44838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwzf3-0005YN-9j for patch@linaro.org; Tue, 05 Jan 2021 22:39:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwzeg-0005XL-7Q; Tue, 05 Jan 2021 22:38:38 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:60159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwzed-0006Fm-LV; Tue, 05 Jan 2021 22:38:38 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4D9ZpG28fnz9sVy; Wed, 6 Jan 2021 14:38:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1609904310; bh=WIP3Li0A1RWtQCRsapwk6616aNsCUjuJfUoLZNg9Opg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l0KD/6fUvrYIWmfW2fdSlFMXoW3qPD5bwaNWD1McmnGa/Azb1OtBsPyv0YLiiwCcX DS/KhMu9rKLLYRIKiWS/43PCuKxdPCAsWRv8P1jB2E8K/TRbKu3ePvYDXPG+Ko9lyR qTwbPY5t9YsemkS7sxc5j30nLDv3Cdo3+aaNXRMM= From: David Gibson To: peter.maydell@linaro.org, groug@kaod.org Subject: [PULL 03/22] hw/ppc/virtex_ml507: Drop use of ppcuic_init() Date: Wed, 6 Jan 2021 14:37:57 +1100 Message-Id: <20210106033816.232598-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210106033816.232598-1-david@gibson.dropbear.id.au> References: <20210106033816.232598-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-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: "Edgar E . Iglesias" , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Switch the virtex_ml507 board to directly creating and configuring the UIC, rather than doing it via the old ppcuic_init() helper function. This fixes a trivial Coverity-detected memory leak where we were leaking the array of IRQs returned by ppcuic_init(). Fixes: Coverity CID 1421992 Signed-off-by: Peter Maydell Message-Id: <20201212001537.24520-4-peter.maydell@linaro.org> Reviewed-by: Edgar E. Iglesias Tested-by: Edgar E. Iglesias Signed-off-by: David Gibson --- hw/ppc/virtex_ml507.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) -- 2.29.2 diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 07fe49da0d..b26ff17767 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -43,6 +43,7 @@ #include "qemu/option.h" #include "exec/address-spaces.h" +#include "hw/intc/ppc-uic.h" #include "hw/ppc/ppc.h" #include "hw/ppc/ppc4xx.h" #include "hw/qdev-properties.h" @@ -95,7 +96,8 @@ static PowerPCCPU *ppc440_init_xilinx(const char *cpu_type, uint32_t sysclk) { PowerPCCPU *cpu; CPUPPCState *env; - qemu_irq *irqs; + DeviceState *uicdev; + SysBusDevice *uicsbd; cpu = POWERPC_CPU(cpu_create(cpu_type)); env = &cpu->env; @@ -105,10 +107,19 @@ static PowerPCCPU *ppc440_init_xilinx(const char *cpu_type, uint32_t sysclk) ppc_dcr_init(env, NULL, NULL); /* interrupt controller */ - irqs = g_new0(qemu_irq, PPCUIC_OUTPUT_NB); - irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]; - irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]; - ppcuic_init(env, irqs, 0x0C0, 0, 1); + uicdev = qdev_new(TYPE_PPC_UIC); + uicsbd = SYS_BUS_DEVICE(uicdev); + + object_property_set_link(OBJECT(uicdev), "cpu", OBJECT(cpu), + &error_fatal); + sysbus_realize_and_unref(uicsbd, &error_fatal); + + sysbus_connect_irq(uicsbd, PPCUIC_OUTPUT_INT, + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]); + sysbus_connect_irq(uicsbd, PPCUIC_OUTPUT_CINT, + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]); + + /* This board doesn't wire anything up to the inputs of the UIC. */ return cpu; }