From patchwork Wed May 8 17:45:03 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: 795503 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:34e:ceec:bfcd with SMTP id k28csp904039wrc; Wed, 8 May 2024 10:49:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVYUKuFrr/hMT7nA34sVrJ6GgDtql5pu4Z9TUPUAomQa+3JqfMTY7cVUMAfKtYOYBv6MI+qoSkrjursL7jrJAdK X-Google-Smtp-Source: AGHT+IETGdt8yg0nAiQgUmSFs0YPCj1OLA83aZ0AwTZxKBpZcVHGTifeU3Jm+b13EYlfq3V4xpDC X-Received: by 2002:ad4:5941:0:b0:6a0:c903:7226 with SMTP id 6a1803df08f44-6a15146e420mr38773006d6.34.1715190548096; Wed, 08 May 2024 10:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715190548; cv=none; d=google.com; s=arc-20160816; b=Jtubq1/K1RdDC9Y6/E13NwQ21oUO0NDTfhYuykFmhlA9gtSvPC9f+ieQTnjoLnaJuQ 4u2e074/UF4rWvq+GcqhN3gA0hE6FR1rPxvM17e9bZaSqwzCeBzRCYC0JLwh6OimCg3p fWqxPZ/s1SX/23cHQL1TxuR5GOtNgopmW4aVgpMdSrFkybeoyNQEy1ikat0PkIlakNEM rf+TB7sx53Mw0qskt/erIBD/tPqNi1Dj2mWdZnIRqk+QXIz++fllD83W9N3xVYJQtz/o oa2FYdFSW45JJHJP0Q2bPa0BpjrhZ0ysdPlBY/OqDT42HTf8IqpAI9b+XEBXx+riHnu6 ouBw== 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=6IRJ9iX2zSqDzHgdCfHrvq8rCQLk6y62SmHm2Vf+BCI=; fh=ci0nbht0+iN2H1U4VN9Y8uZzyBlZoOCHT2Hqs31ZAGI=; b=W6G9SZ1LOJCkcnrP59qRnVkUOzbtvAtmbwKatJk4ePLskfaVjnnEI5u+cYicvzCuFI yenHTYs2LvNEzjo+yEsm2Ob9+p1UgDRWmHzwHKoT2zzW7w7BiwZEaoOUUOizEjZfd6XY 18mlCGeDqqDLt54MJTM4xLIXbm/qYdmfCkbiZZckXoUbwuo0BT0GyMzf9qChcU80A+Sj zPZedhicG2/1YKa0CC7fBXv8SU/6UZGbgJoJbLVBapnhNutD8MjnuJxSJ2jIhpprgltH JH/9NoZ20JBHop3vKLEIcPhLSh65ZIcjuQPEJoLwTtiCkVrbPbRM7Jv2p+Xovi47rC8N iq0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ekDCImcu; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f9-20020a0562141d2900b006a0af3c9124si414318qvd.358.2024.05.08.10.49.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 May 2024 10:49:08 -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=ekDCImcu; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4lNy-0003b3-3r; Wed, 08 May 2024 13:47:24 -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 1s4lNi-0003Ig-5l for qemu-devel@nongnu.org; Wed, 08 May 2024 13:47:09 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4lNZ-00009b-U2 for qemu-devel@nongnu.org; Wed, 08 May 2024 13:47:05 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a59c448b44aso985115766b.2 for ; Wed, 08 May 2024 10:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715190416; x=1715795216; 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=6IRJ9iX2zSqDzHgdCfHrvq8rCQLk6y62SmHm2Vf+BCI=; b=ekDCImcuXYSxXgmg0MuXw6Vn6TMlfXjcj07d1HgE5UiqzcZCvDAUy1PqygzQvyWFyJ KPnKKgcF7TPejfYERtvRr/dMv++f4wkmHHQPUe0CqzhQVhCBrPV8x+FAgnURCsMKbGJb BMiUF/JxKW3qxx23N4uuJzSBgqpggqV0FJZws1ZhutdBbv4ocuImT7mEiemzabv7J6lP cSqn3Y0CTBThnlbrr4/LIAzAFcM9qBBbDXdszF83W8p88Lz7OSq034WawZTOU7CfSQmu na3OHU/hcHtWgV9t+QmA0lGvTy5h+pQUnxaRu6RwDvmyHL5Rt4MOkCZuI4ceiSwHTMJ2 Ljcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715190416; x=1715795216; 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=6IRJ9iX2zSqDzHgdCfHrvq8rCQLk6y62SmHm2Vf+BCI=; b=M3NwmXAZ1o6rYpQg+pTaS4wwxtficVJsWVCII8w+3tyWKaNOMSLQmuawXS2TBL6+d/ ggSb70M7W2AWj59YK7eiPz/h/5cMdR7vL23F0Tgy1+mRvMyVA7L8f1LLp8cHZDRrSUSp OxHUtR+YqTCzLDGSsM4OxlBIt4zTME6EHDlAVvStOCwAr0SCDzImJc2LacpH3XvMRkHK rDIaHSEExwkl1FV6Z5cWD1hC6QshLskuWe7mp1XgDKI7hJLMuju39cfVY+/f13PQCtcR ghkfBpt8hzUOy5Znw/wbJlxB3+LXnHLZkRIae1KFR0G8qz+SrnAGAP9pQncaxxCdLy5l oV6g== X-Gm-Message-State: AOJu0YxOA9rCSM5WkKA+lB/JhNNI6kJ7iYsNdZUhIhGQIRoa7pGZwGzi nOY5xSXqpDYfMzOSr5HjpWtJEZXk88hoenlCD9rvTMYn0PuO+ydPz6bDSlWKObBtwlxQeY57msu k X-Received: by 2002:a50:ee10:0:b0:56e:60d:9b16 with SMTP id 4fb4d7f45d1cf-5731f04235cmr1998594a12.6.1715190416264; Wed, 08 May 2024 10:46:56 -0700 (PDT) Received: from m1x-phil.lan (sar95-h02-176-184-10-250.dsl.sta.abo.bbox.fr. [176.184.10.250]) by smtp.gmail.com with ESMTPSA id n18-20020a05640205d200b00572f0438b02sm4654580edx.6.2024.05.08.10.46.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 May 2024 10:46:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Song Gao , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 19/26] hw/loongarch/virt: Fix memory leak Date: Wed, 8 May 2024 19:45:03 +0200 Message-ID: <20240508174510.60470-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240508174510.60470-1-philmd@linaro.org> References: <20240508174510.60470-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-x62d.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 From: Song Gao The char pointer 'ramName' point to a block of memory, but never free it. Use 'g_autofree' to automatically free it. Resolves: Coverity CID 1544773 Fixes: 0cf1478d6 ("hw/loongarch: Add numa support") Signed-off-by: Song Gao Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20240507022239.3113987-1-gaosong@loongson.cn> Signed-off-by: Philippe Mathieu-Daudé --- hw/loongarch/virt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 504e1fb349..69924a8734 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -884,7 +884,6 @@ static void loongarch_init(MachineState *machine) const CPUArchIdList *possible_cpus; MachineClass *mc = MACHINE_GET_CLASS(machine); CPUState *cpu; - char *ramName = NULL; if (!cpu_model) { cpu_model = LOONGARCH_CPU_TYPE_NAME("la464"); @@ -943,7 +942,7 @@ static void loongarch_init(MachineState *machine) for (i = 1; i < nb_numa_nodes; i++) { MemoryRegion *nodemem = g_new(MemoryRegion, 1); - ramName = g_strdup_printf("loongarch.node%d.ram", i); + g_autofree char *ramName = g_strdup_printf("loongarch.node%d.ram", i); memory_region_init_alias(nodemem, NULL, ramName, machine->ram, offset, numa_info[i].node_mem); memory_region_add_subregion(address_space_mem, phyAddr, nodemem);