From patchwork Tue Jul 23 20:38:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813975 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2489198wro; Tue, 23 Jul 2024 13:41:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVVDz27543RKFqAq6ryjA1wFOluWob3hMsw8RKVNr4rRtg/QayVCTJPkrcBL0nDezbL0DMeopH/J/t1C+ghmUfW X-Google-Smtp-Source: AGHT+IGpV3hXdZowKNwRDqllKKAJySwEIO+7AzWeCpffO7XeY5KxSznqH4CfDsEbNMDPUwAQn2Vd X-Received: by 2002:a05:620a:171e:b0:79f:1985:b602 with SMTP id af79cd13be357-7a1a133dc89mr1614718285a.39.1721767266875; Tue, 23 Jul 2024 13:41:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721767266; cv=none; d=google.com; s=arc-20160816; b=e/nDlg499TsYO7/FcdI0doLf0N5lGimOmPIxLQjvrc2KCqcDq1sS/f5V3yXWBF6Sx6 uvb/aUK42Ym8XLVN6wwemV5tRgC6UYNz/kTJogagggC5Y7gi+5tyoOW0HJQbPBVxZK5u W0i3FLZ2fEaIBHu529V8Lt8YXRVPxlDIam/odq361lUR3AXo413IDtsLorYdOzDp4HB/ X6Z6KYA4dn93tGHitUPBBj9X/ryX5RXm7d/cZEuz5KMtXFcQNM5OE74LtRF0EIYG1fEW nlYqJVNFOlZ+ocCcQsrOSKI+XKD+9lsxP1QROkfXNfpP81W+qZSS7fNyo1fHgQXvuf17 p/IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=SEw2US0MusaevsyReo4Qy9oebugC1Q09g9E1j6NjCoM=; fh=d63FR0c3ETih8ywwL708/MYK/WmikiRunAdgFdVU+Zw=; b=zPlYCAN3Vr3afFdm2OBPeSiavHiZhfRWdkQSC6DMRmyiT1Sx0oswxwrvziL8UNi8M7 NPLVPKKSDmSk23730v3j41b/PfBRhX+IKDzg3RqOQPmtmJFZfskacUqs2gkWpjHZW0XJ RIS9tbHFdOo6Lokcaxpwnl6IWi73HW6NwLUbd724fvyY8fjGaujw8hAYL1OxnnTmCA9e G/N3iUu3pICfJuKcpLAVZaCQQFuP94VTxwu5iUNdPH672IHj1Ee+XUrHBJhvuLGIOrtd 1VpkEVn/6XW5XPL/CaufBCuJ+h9W7A9+NVTJKNuqjmGDAhG34IZ21PRdCsq2DHj41/E8 Gpyw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YkfBe30e; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a19906d76fsi1107224885a.521.2024.07.23.13.41.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 13:41:06 -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=pass header.i=@linaro.org header.s=google header.b=YkfBe30e; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWMIA-0003zM-PB; Tue, 23 Jul 2024 16:39:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWMI9-0003wc-2O for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:39:25 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWMI7-0003w8-GS for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:39:24 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4277a5ed48bso44883335e9.2 for ; Tue, 23 Jul 2024 13:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721767162; x=1722371962; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SEw2US0MusaevsyReo4Qy9oebugC1Q09g9E1j6NjCoM=; b=YkfBe30eIKZlLqI1KrdgrBb36cSgtV1XZNT0ah+gTUvYC84wCgkVRjcRictcqO6eUM CIPqcv1F8Nq1BEChvhXu9MWdx9BTAL7TtZXBLeyHUeF5i5OB3QMzQ3oRe/BxnCXZx7vQ /MAoN+pVQli1Ns9v/7DfoGKaFVLgPyE7MPQ/8aCxj06fjUJtF5703PLr51lxHzUigsrL FWxy7LnUgFnnGN71ovlawJtXYvP4mUGNAXCPC8g9IQEhKS22Y8aTebWH/iMaOBydUZZc OqdQfrgQ3YzCLSznQAxyjaKosZtoT+RlwpfTRy71vhvcnHxwz1r9j1hj4zyA6p7crBe+ Vlcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721767162; x=1722371962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SEw2US0MusaevsyReo4Qy9oebugC1Q09g9E1j6NjCoM=; b=S9fJqyawedkOAr8e4yJEzzDiwqRn1TzeUYWfLZgQ6KXZaqJkS2Ztclla4xpHbzEhcV Ywz1xrBUjrarEydKd++RecRp3FbtpfwXC75As/n1Swm10vo0HoZ1PvLidff7zlSAur56 IhFcQTdOYbZZjB7098iA4FCIqNld0AQ5j3KRbDxq8oG7MXsymzoUKQxfIAzxWx3v1NTq pr+2k+cPi5Fm7/88DJVAMrvyMxXFvLshfyaHGFbwKGkkvYa60HgCQx5Yz5ot10Czf5dB V/lsm41tEaOOP/WB/uweBZkMVJu3nL5XS550jT/qRNSneJ3yEZao58bc3sMJvoukY9x8 PcDw== X-Gm-Message-State: AOJu0YyQrYQ8MCdEWmlgbFoW9tuh4lJ3K9BrgRBC0yCvXbZ/Ol0Eo77n kqa3bhB/14IhTxbWV6OcQKl+fGhmfOO/Xqq/6uyIwO/vR2MaHm1jjUn9tKVevwPfv9itomx1Fbk rz5I= X-Received: by 2002:adf:ee48:0:b0:367:8383:6305 with SMTP id ffacd0b85a97d-369f5b14530mr35690f8f.55.1721767161794; Tue, 23 Jul 2024 13:39:21 -0700 (PDT) Received: from localhost.localdomain (vbo91-h01-176-184-50-4.dsl.sta.abo.bbox.fr. [176.184.50.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f93e65a7sm319175e9.33.2024.07.23.13.39.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Jul 2024 13:39:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org, Song Gao Subject: [PULL 04/28] hw/intc/loongson_ipi: Fix resource leak Date: Tue, 23 Jul 2024 22:38:31 +0200 Message-ID: <20240723203855.65033-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240723203855.65033-1-philmd@linaro.org> References: <20240723203855.65033-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Once initialised, QOM objects can be realized and unrealized multiple times before being finalized. Resources allocated in REALIZE must be deallocated in an equivalent UNREALIZE handler. Free the CPU array in loongson_ipi_unrealize() instead of loongson_ipi_finalize(). Cc: qemu-stable@nongnu.org Fixes: 5e90b8db382 ("hw/loongarch: Set iocsr address space per-board rather than percpu") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Song Gao Message-Id: <20240723111405.14208-3-philmd@linaro.org> --- hw/intc/loongson_ipi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c index e7979dbdd8b..4013f81745e 100644 --- a/hw/intc/loongson_ipi.c +++ b/hw/intc/loongson_ipi.c @@ -318,6 +318,13 @@ static void loongson_ipi_realize(DeviceState *dev, Error **errp) } } +static void loongson_ipi_unrealize(DeviceState *dev) +{ + LoongsonIPI *s = LOONGSON_IPI(dev); + + g_free(s->cpu); +} + static const VMStateDescription vmstate_ipi_core = { .name = "ipi-single", .version_id = 2, @@ -353,23 +360,16 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = loongson_ipi_realize; + dc->unrealize = loongson_ipi_unrealize; device_class_set_props(dc, ipi_properties); dc->vmsd = &vmstate_loongson_ipi; } -static void loongson_ipi_finalize(Object *obj) -{ - LoongsonIPI *s = LOONGSON_IPI(obj); - - g_free(s->cpu); -} - static const TypeInfo loongson_ipi_info = { .name = TYPE_LOONGSON_IPI, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(LoongsonIPI), .class_init = loongson_ipi_class_init, - .instance_finalize = loongson_ipi_finalize, }; static void loongson_ipi_register_types(void)