From nobody Tue May 14 07:25:17 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=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1683114962; cv=none; d=zohomail.com; s=zohoarc; b=iPFUlhAmR5WHw7OjGp3bcTz437lJ4AmRMmp0pJMxRSqcmUsu1brCR9+Po6yiIDd4Fe/kspPn4NwVk48W2ewbF9rf+nLObBLYcDvZn33Xk7loEE9Gsk2v4GKcP26TASwd8sgbt2AKdAAjohOISltyZpUCVmI8hXtS4aHWHx0vNXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683114962; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=7pgI9GbithIVI7QR54i0GOM4iaL1+6pZCz6AZ+iH2xo=; b=Yq/Ikd7ZL6F5Mcwv/YDKTSh4MJdT0oUHoAhAToU9I2i+fMvp4vdUwJgLW/ev33lgqnc9ojAXET6nV4EL8kgUl98+iZn+ByaB6QOyKfHmYXqBV55cW9RIxRYd5X16kjADNdtbR1FVTEfCLcH3CllvSg9Qn7fdcnVvpeuVE+Fj48E= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168311496278298.5620210557264; Wed, 3 May 2023 04:56:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puB4X-0001zg-5m; Wed, 03 May 2023 07:55:01 -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 1puB4V-0001wM-4E for qemu-devel@nongnu.org; Wed, 03 May 2023 07:54:59 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1puB4J-00012P-Rf for qemu-devel@nongnu.org; Wed, 03 May 2023 07:54:58 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-63b5465fb99so3994313b3a.1 for ; Wed, 03 May 2023 04:54:44 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id 136-20020a63008e000000b0051806da5cd6sm20039586pga.60.2023.05.03.04.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 04:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1683114884; x=1685706884; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7pgI9GbithIVI7QR54i0GOM4iaL1+6pZCz6AZ+iH2xo=; b=Xc050Or+O8CDj90Dgiv9CAGz5oltY07/F27VPDDOwPTbWjJjR68TQ2DgDDMxRfHfPA wj9qHstlz2KlOkiu25VFh6Nk5a8Y3s5sAvmmyqSRrbeWaYul2Mxrrhct8g2KRIwyICHG oirr65UqYsLu9wsG6TKrSBNq8DWu4RSoPjE9Uo7dX60ZTCCbIvM0MLPJwWOI9SA/PSCM MmKlhTlSRGjod08AqUuWdWxqdGtT318NY6aUT2EVAjcoE9RYU+M4TJ/xB0g8wDJmW/FR FRf4jBQGhY369zFw6IUMK+WjUVwCY+kYMFs9O+ow17+fFE6kD/0ozP3LkZmg/qGqddMM kvMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683114884; x=1685706884; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7pgI9GbithIVI7QR54i0GOM4iaL1+6pZCz6AZ+iH2xo=; b=UOQMFjaZoEB0USM9tdNRDoH+PuV/gGOEB0FNMY+7OsFHcMO4ccwAVvU3y6MDYjkC+Q FKkSCiODb5ThxCgqdihTiw0B08cGQMM4TeRj5belXCsTnpyTEnyRtTykzpFrgf9pt26P nGyGfa+gl751NQgIoODphVh910R2QL6KqE4KSIR+PH1E9JJawlyyGjbneJ925nAVd6Ei iUByE9TvZdlP7ZSHNA8To8duvjE87HK/Bw/zoBlKmGkdxKzZ2CQW82v9+6wFnJPAX5qE XQn84lOnu2pjU/IguLAkc+IuEH7e9oCkAU5OFQZbDSulXalatIUopz73iBixrP8Vus29 VzyQ== X-Gm-Message-State: AC+VfDyoRF0oHvZhE1M7VdHyobj0rhKYX12m6BNig1rT22erSfbDJxYl eshMhVQtRaEEmu2J7abIJGUFHQ== X-Google-Smtp-Source: ACHHUZ5hzvhElq4ek+vImQUmI0QFCnR3VhsiyapRAz2Y8F7/05GBxsWiafUwzuJkXGd/zp/lzQ8WpA== X-Received: by 2002:a05:6a21:7884:b0:ec:88e1:1452 with SMTP id bf4-20020a056a21788400b000ec88e11452mr25421527pzc.62.1683114883792; Wed, 03 May 2023 04:54:43 -0700 (PDT) From: zhenwei pi To: mst@redhat.com, arei.gonglei@huawei.com Cc: qemu-devel@nongnu.org, zhenwei pi , Peter Maydell Subject: [PATCH] cryptodev: fix memory leak during stats query Date: Wed, 3 May 2023 19:54:37 +0800 Message-Id: <20230503115437.262469-1-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 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=2607:f8b0:4864:20::434; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1683114964183100003 Content-Type: text/plain; charset="utf-8" object_get_canonical_path already returns newly allocated memory, this means no additional g_strdup required. Remove g_strdup to avoid memory leak. Fixes: Coverity CID 1508074 Fixes: f2b901098 ("cryptodev: Support query-stats QMP command") Cc: Peter Maydell Signed-off-by: zhenwei pi Reviewed-by: Peter Maydell --- backends/cryptodev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 94ca393cee..7d29517843 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -522,7 +522,7 @@ static int cryptodev_backend_stats_query(Object *obj, v= oid *data) =20 entry =3D g_new0(StatsResult, 1); entry->provider =3D STATS_PROVIDER_CRYPTODEV; - entry->qom_path =3D g_strdup(object_get_canonical_path(obj)); + entry->qom_path =3D object_get_canonical_path(obj); entry->stats =3D stats_list; QAPI_LIST_PREPEND(*stats_results, entry); =20 --=20 2.34.1