From nobody Sun Nov 24 12:08:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1724165440; cv=none; d=zohomail.com; s=zohoarc; b=VjTU4wZKgD1SCAEejZX+ikXuVB+7gzCLneG52Dhw69dnUM2zd6Pk1hiI5wbMjkTKKJ4KpeqfGsB90sRC9WNQ7Gy20ltdLBZCMMAwR8m6EnB1kvdmXvH0ozH3MwZS1YRzTLKz3nB3PpeXLC+zV/FNZTK8IVlWmnA98OPeeUozoOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724165440; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CAsHK7noev/bPNR4RNcwASEP9niT1BKYeUYjWLvcQsM=; b=A0Bkb3pqjvYdbsT6D5eRWoyj8MEdthZ6mZ4+IP11JQ06gpOYmns/mdjDom620u3FGxZrGjbHqR/WCYazzxBccXJSAfyzaCu/owlM+R8TivFEiS3Eirvv4oJAlo6HFWzTxmg4XHqmHbRdX4kD9hJymx3efrggqYDYc4Ozr8wouNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724165440580120.58100254718329; Tue, 20 Aug 2024 07:50:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sgQB9-0006KZ-I8; Tue, 20 Aug 2024 10:49:47 -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 1sgQAv-0005je-1e for qemu-devel@nongnu.org; Tue, 20 Aug 2024 10:49:39 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sgQAh-0006LW-IQ for qemu-devel@nongnu.org; Tue, 20 Aug 2024 10:49:32 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-367990aaef3so3494883f8f.0 for ; Tue, 20 Aug 2024 07:49:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3718983a306sm13334672f8f.15.2024.08.20.07.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 07:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724165358; x=1724770158; 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=CAsHK7noev/bPNR4RNcwASEP9niT1BKYeUYjWLvcQsM=; b=XErvckPsnWK0oGlnAykzftnBZMoMKb53qyA35fcdKdWo/kKonbG+urq9dBYVn+UA9j XLSXND/6OnNcVLm6L3XrHE8bZPhopuZGlfKh8SwgnvNDc//AUTc5OMQqumypnJ1qEi5X A+G+Lvb6phRDsGPzJaqNxTghGsnsnaIERlIRedUub5q9z/njaupw64VO2x9bQimI66XF vh3v1xNey8WhLwvLpyO7CTSINI93LZ/02M/voZ9RFYv5qlbxbQxngfaIDxOIkmXlpVe3 uS6GeZTlH5Z3uSI+jtXh9ZK+2ZvmhSkB5jaWQiF16Z6uFKsSWNYCaOq2SCWN5Ebk3ltj qD2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724165358; x=1724770158; 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=CAsHK7noev/bPNR4RNcwASEP9niT1BKYeUYjWLvcQsM=; b=GFFd4rXmJRknBfJsIvgl0iehD28WuKpMSKsEFGcLNwWF/pFwJgkYf5t1DZRywdUTls TNKF2BQepvdCvSC1KvmD55FdK/HKqPVozRPb4Yyn/YSGZ6OPkdWZ4yvRALSXHDy010lY vjAN8RYphZjJ8Q21oRXHa7+81YlEkL1KVIVoeB4gRNzaWW52uiqQWqX+rt6VI1G7duZb 9kToi3d4IWeivAseMn6YSwpwkCe1Z5FN6nh2psJpFZPN9EH8YqCE57aYbOevwRyeSSHo icxmNFnLyXK5f/qJhYsE/8u7zXqaKoWxBCbGyW/OCjWWdnQ0X1SYuUSUS31PgKtE9Lxz 4JAA== X-Gm-Message-State: AOJu0YwibiiLZ+dYnkMR3YxpO5cjS33CwLZj8vRxjq47qpyxey1Mcudv FDrZ5f97wxpxeP95NA8aZmJu0ZGX0inq/gmR1OklBi+DR7mtEtMFiL7HGh4BDKUEgzdZxYn2nIL M X-Google-Smtp-Source: AGHT+IE/5KkZylplrHDrwD7Qjrx9dt8R5kjq7PFwLQIF2+zzDrxVHH5xe4qAgRxWFps99fcnExhAiw== X-Received: by 2002:a05:6000:e4d:b0:371:93d2:ce49 with SMTP id ffacd0b85a97d-3719468e998mr9256549f8f.44.1724165357684; Tue, 20 Aug 2024 07:49:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH for-9.2 7/9] tests/qtest/migration-helpers: Don't dup argument to qdict_put_str() Date: Tue, 20 Aug 2024 15:49:10 +0100 Message-Id: <20240820144912.320744-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820144912.320744-1-peter.maydell@linaro.org> References: <20240820144912.320744-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1724165442515116600 Content-Type: text/plain; charset="utf-8" In migrate_set_ports() we call qdict_put_str() with a value string which we g_strdup(). However qdict_put_str() takes a copy of the value string, it doesn't take ownership of it, so the g_strdup() only results in a leak: Direct leak of 6 byte(s) in 1 object(s) allocated from: #0 0x56298023713e in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu= /build/asan/tests/qtest/migration-test+0x22f13e) (BuildId: b2b9174a5a54707a= 7f76bca51cdc95d2aa08bac1) #1 0x7fba0ad39738 in g_malloc debian/build/deb/../../../glib/gmem.c:128= :13 #2 0x7fba0ad4e583 in g_strdup debian/build/deb/../../../glib/gstrfuncs.= c:361:17 #3 0x56298036b16e in migrate_set_ports tests/qtest/migration-helpers.c:= 145:49 #4 0x56298036ad1c in migrate_qmp tests/qtest/migration-helpers.c:228:9 #5 0x56298035b3dd in test_precopy_common tests/qtest/migration-test.c:1= 820:5 #6 0x5629803549dc in test_multifd_tcp_channels_none tests/qtest/migrati= on-test.c:3077:5 #7 0x56298036d427 in migration_test_wrapper tests/qtest/migration-helpe= rs.c:456:5 Drop the unnecessary g_strdup() call. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas --- tests/qtest/migration-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 7cbb9831e76..a43d180c807 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -142,7 +142,7 @@ static void migrate_set_ports(QTestState *to, QList *ch= annel_list) qdict_haskey(addr, "port") && (strcmp(qdict_get_str(addrdict, "port"), "0") =3D=3D 0)) { addr_port =3D qdict_get_str(addr, "port"); - qdict_put_str(addrdict, "port", g_strdup(addr_port)); + qdict_put_str(addrdict, "port", addr_port); } } =20 --=20 2.34.1