From patchwork Tue Mar 24 19:55:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 184782 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5757554ile; Tue, 24 Mar 2020 12:57:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuScRH8uJudaY4k46Z39iNs/wQianBMgbztsaR/aecNG6dzQPerjlrc7TT1x4voSBhLDwxs X-Received: by 2002:a37:7245:: with SMTP id n66mr10675762qkc.303.1585079878248; Tue, 24 Mar 2020 12:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585079878; cv=none; d=google.com; s=arc-20160816; b=VSjunD/fIHSmYt+5qfceHC6A68WQrMf3vXehiTJOEfJZfIgAyameG4qWMnvsddnjoB 1OABnDKknS2p2jhMPull3bdbAhuVI+lWKoMqcvFKVPy6XrRGidZlnQWwbCJYfew3h/Sz Uy0+oeEHolOSbAKfrKJf/op7dBnYMIFeaGaz1CqexuhGO8eUQoZE12AxPJSktH7d1R9b RZTVmeSF/ESn+OYCFwl2af4wiiYzDqrWJP/e+6iwrzdbQiJKHzjOGWUOGS6wXHAkAh3I 1oDsB9999n4vtOO4/szhPQKfJW56XFHRGI+9EHH4QQSG+lTjlMeW655GVUsNe8hPEjyb 7hAw== 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=zQFNGKhJkuckNqnn3T7IwEfqRFWlsvZN8tLTUAXGp1c=; b=cHq+03ndIFAvpdWiePwrUzq2MnoEUmm2tvWCfL+XBHwLG3p7vF5Bb+0/2s4aHwNfpZ /+ookE89/0viEpQ9JUAmbI7jd1qfTZiZ0yLAWDIgftw7BcQOZE/Gcxun5fF0nrr3o4ca uj4ayF6cJzW66WFaVE/g76r1yGlu6evPHcURKZCWKFhsIqjquUSetflGhUWrqcf4HsVH kfrOj0UPAbAO5vaRc5wkZo7mQJQC7Ki4au4Y+624E70OssIVcl9vKWLhIq1ZYyaOpxiT nCNXpgNY0B8ew0iEp0+Dx6uHehkSCby9U+lyQ0O9ZfxjRj6Koz2em6X+fIMUb40xm/OI eakg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=Wq2pjnIJ; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18si1287762qke.232.2020.03.24.12.57.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Mar 2020 12:57:58 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=Wq2pjnIJ; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:54285 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGpgT-0006ed-PX for patch@linaro.org; Tue, 24 Mar 2020 15:57:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52087) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGpeW-0003t2-Vq for qemu-devel@nongnu.org; Tue, 24 Mar 2020 15:55:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGpeV-0003Fr-Pu for qemu-devel@nongnu.org; Tue, 24 Mar 2020 15:55:56 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:57881) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jGpeV-0003FI-Lw for qemu-devel@nongnu.org; Tue, 24 Mar 2020 15:55:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585079755; 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=zQFNGKhJkuckNqnn3T7IwEfqRFWlsvZN8tLTUAXGp1c=; b=Wq2pjnIJDYk8uYwte49ts0HzGM3p8FoUYzcIw7JX7gIN2uWIbJtUDlvBZ18IC6o3H7RyMw 8K0A1vHbH0gwOSB79MpWOcgkndwG//0DO9kPLRoxMriWn7XWhs5cLfPSyBXC5RxGY/sd9z 4sLXDIVDLki4VJfUL1Rnix89qi9V9LQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-198-mjm4_rAfNomkjpyuPJG-zQ-1; Tue, 24 Mar 2020 15:55:51 -0400 X-MC-Unique: mjm4_rAfNomkjpyuPJG-zQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DEBB9801F77; Tue, 24 Mar 2020 19:55:48 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 183B91E6; Tue, 24 Mar 2020 19:55:44 +0000 (UTC) From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 2/2] hw/ide/sii3112: Use qdev gpio rather than qemu_allocate_irqs() Date: Tue, 24 Mar 2020 15:55:23 -0400 Message-Id: <20200324195523.19779-3-jsnow@redhat.com> In-Reply-To: <20200324195523.19779-1-jsnow@redhat.com> References: <20200324195523.19779-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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: "Michael S. Tsirkin" , Mark Cave-Ayland , qemu-block@nongnu.org, Helge Deller , =?utf-8?q?Herv=C3=A9_Poussineau?= , Aleksandar Rikalo , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , John Snow , David Gibson , Kevin Wolf , Max Reitz , qemu-ppc@nongnu.org, Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Coverity points out (CID 1421984) that we are leaking the memory returned by qemu_allocate_irqs(). We can avoid this leak by switching to using qdev_init_gpio_in(); the base class finalize will free the irqs that this allocates under the hood. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: John Snow Tested-by: BALATON Zoltan Message-id: 20200323151715.29454-1-peter.maydell@linaro.org [Maintainer edit: replace `DEVICE(dev)` by `ds` --js] Signed-off-by: John Snow --- hw/ide/sii3112.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.21.1 diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c index 06605d7af2..d69079c3d9 100644 --- a/hw/ide/sii3112.c +++ b/hw/ide/sii3112.c @@ -251,8 +251,8 @@ static void sii3112_pci_realize(PCIDevice *dev, Error **errp) { SiI3112PCIState *d = SII3112_PCI(dev); PCIIDEState *s = PCI_IDE(dev); + DeviceState *ds = DEVICE(dev); MemoryRegion *mr; - qemu_irq *irq; int i; pci_config_set_interrupt_pin(dev->config, 1); @@ -280,10 +280,10 @@ static void sii3112_pci_realize(PCIDevice *dev, Error **errp) memory_region_init_alias(mr, OBJECT(d), "sii3112.bar4", &d->mmio, 0, 16); pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, mr); - irq = qemu_allocate_irqs(sii3112_set_irq, d, 2); + qdev_init_gpio_in(ds, sii3112_set_irq, 2); for (i = 0; i < 2; i++) { - ide_bus_new(&s->bus[i], sizeof(s->bus[i]), DEVICE(dev), i, 1); - ide_init2(&s->bus[i], irq[i]); + ide_bus_new(&s->bus[i], sizeof(s->bus[i]), ds, i, 1); + ide_init2(&s->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&s->bus[i], &s->bmdma[i], s); s->bmdma[i].bus = &s->bus[i];