From patchwork Fri Mar 27 20:14:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 185022 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp1731921ilr; Fri, 27 Mar 2020 13:20:05 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuSatYBDeaA8JCAZyusooa1kdDzqSjo7sz6/KDieVV3fl8ZM27pzrIK3A0w4Efmzn3+UDSv X-Received: by 2002:a37:454c:: with SMTP id s73mr1118415qka.92.1585340405201; Fri, 27 Mar 2020 13:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585340405; cv=none; d=google.com; s=arc-20160816; b=JK4l65rjRnxW5F/2rfhgxvuC1Lk+BZROi/L1QaClptHGn+/SdLMQkYTrNTh++2lZnF XLJelr7GyYDsXf6JKtIiCIn9btK3bQ9B9GFiLflT2EhFk7pmwJxBn1lNOwykwvQk4sT4 vki8nd11un7wzf7GLZVw2EWPIHbiP7jG8orpSbC1LFQZvHB/XQPTUBsOLaQG/IrDGLJw hJ1ey71pe+3Vb1zds6D53//a0baiNgm/u+0gat1qP1gLmwwpcPnXw9BMbhMFGUH4j6Yd rm4mkk+iH/J0S+SZPF2nbjqiXMJXWjt8OG0TXEQ4Trv449DkJXMGdtPV/ZEStejRWbxR F+5w== 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=NVhQoLMKP9TYJGXDAv/5CL8J6QAGwwR248U0m+cGTu/4g2FrMUGRcVIL+fOnYCv78m aSk9UemcQEePW87t0ibxHFMujUABPAe+QmuwJ6WnOIbyUWt0na3pief4BxxRse3ex7/W dsidt/0FuKaEgsk+22F/D82B1dTWioNbDxehYYQVHPswvVnH48mq0+vQ3AO10bfCeLuh 7D2HEEOHVqwMojSMhDBTUYMNgkSW25OeLQCGsa+29nnZoWRtCvZkbcWC7LkykfJf05Eu YMBeOTiW309KLMIDzwc7XOJJUev2B6qFXZ+45eDaWGhBIG6me4UoVxXuqMVbw8lUuVxv wcBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=iRriy04f; 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 b1si3788025qvv.217.2020.03.27.13.20.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Mar 2020 13:20:05 -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=iRriy04f; 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]:46518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHvSW-0007tK-Op for patch@linaro.org; Fri, 27 Mar 2020 16:20:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57785) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHvO6-0002Fd-DH for qemu-devel@nongnu.org; Fri, 27 Mar 2020 16:15:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHvO5-00036Z-2x for qemu-devel@nongnu.org; Fri, 27 Mar 2020 16:15:30 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:20753) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHvO4-00035C-UV for qemu-devel@nongnu.org; Fri, 27 Mar 2020 16:15:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585340128; 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=iRriy04fTFI305HxNdrL2Ukq8Ry2nXAUrzxuiXqSXYmew9KKUBe6QrenP7rXJa5KkQSldH QUfSwpbDuEYMBp/4JONj9PF2ZItGJggdtCEYaYezaHL7PN+V66BVqUV9auBHd10HvscRTR ibYnBl4yOpovpxnLgv+/OOhCJAwVoo4= 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-98-63m6sd7hMv2m9i_kiFuqZA-1; Fri, 27 Mar 2020 16:15:24 -0400 X-MC-Unique: 63m6sd7hMv2m9i_kiFuqZA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3616D801A0F; Fri, 27 Mar 2020 20:15:22 +0000 (UTC) Received: from probe.redhat.com (ovpn-113-210.rdu2.redhat.com [10.10.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 889BD166AE; Fri, 27 Mar 2020 20:15:18 +0000 (UTC) From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 2/5] hw/ide/sii3112: Use qdev gpio rather than qemu_allocate_irqs() Date: Fri, 27 Mar 2020 16:14:58 -0400 Message-Id: <20200327201501.1417-3-jsnow@redhat.com> In-Reply-To: <20200327201501.1417-1-jsnow@redhat.com> References: <20200327201501.1417-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , John Snow , Richard Henderson , 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];