From patchwork Thu Aug 22 16:21:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 821338 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp1268534wrm; Thu, 22 Aug 2024 09:23:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXgkn+WLm4/lADYLK9py1SdAkxQtdfphjwb/CWNMVC+WUnaUJTXUHxDQ69/rULBPbx5++C9dg==@linaro.org X-Google-Smtp-Source: AGHT+IHfqBgMLQLYSYYirZHDzYXBNHk9WrgyOS+b0uCnhfOOhfINl6EtreAjbfYEF9XQMWbEFoJx X-Received: by 2002:a05:6122:3693:b0:4fc:eda5:6369 with SMTP id 71dfb90a1353d-4fd044c81d1mr2997584e0c.3.1724343798620; Thu, 22 Aug 2024 09:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724343798; cv=none; d=google.com; s=arc-20160816; b=AgSoKC3aqM4/pLhZK49Jp4XGXfvq7ER/CInqAkNyW4xQ3xbTJBpnpyjtcNN36ublGN 4OGbBJuK402nmpbmc0TGUlKRCA+r/dkWgBS9NunOHy8goMLlgpkyKPc6MA/EQd/XW+/r 40xpRgz5B8krQAiPAUOGRHFJz5HeLQo6sT0YtC9gmZaSU6QVvgLcX6uHYP1SmM1JUFtv yrLNHgdSIuF7pOk8QhIVpfzGqO0cx5oghBQfxfw1SdXJ5zMtJdCgHIx/67ltxSVNe7ih kFhve1L4s3udIzEryZ2XmRYKuNX1uWbkQ0Pj9/XHE8cs7N9izIwa0yGB3Yui0F+TTnUj xQug== 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=WaN7NC9uHrEwXd29tH1+I6/CGeGFysWI1W1y0Mcbdjo=; fh=t/cKOjj/MMAZd9RyqfhKZsbJ3R2nziJURYSgL8HmOwQ=; b=cl2ArhX21/8e0mKtYRe+D3MYytP1w8hGODimfRk5kGPB6U0SV05vEHZ6Uhk7FF5QvE DdRNAzSsGKngkJuk4oTA4GpU7myoupdkigER0XU8xART2D3bTJsMMTibTLWuM1zH9wby NX4SdNT3KMvXDn5MVzY8l2dR/1T6nzA+vafW752qaXPk0K87NWlV/Ctb9zRrLhu5A0wH MGu3JDRygyVhdrlNQoaTNvo/UnaaGTsI+k4KieIAMto5C1HrLKFp4g1RF/fOABgp/STb 26wgA6rJrdvfNuzUIBYAeJEIHrceIBj+g7uwtToDJpBIkqlYjWIPrDT4mqZ7gmxeIkWp PLxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ycL3p/Cx"; 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 ada2fe7eead31-498e49699a0si455570137.728.2024.08.22.09.23.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2024 09:23:18 -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="ycL3p/Cx"; 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 1shAZK-0005Z9-RO; Thu, 22 Aug 2024 12:21:50 -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 1shAZD-000578-Fk for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:43 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shAZ3-0007K3-UV for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:38 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-429e29933aaso7303215e9.0 for ; Thu, 22 Aug 2024 09:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724343690; x=1724948490; 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=WaN7NC9uHrEwXd29tH1+I6/CGeGFysWI1W1y0Mcbdjo=; b=ycL3p/CxwDjA9aCs4o2zK6NceNnnCy9CzXj5b2NG5XH0J+MAwa+WbGXseG6OIkHobU Xvtkc7vugvzTXfKUSZZ8rcSkE3E3BKYVwICNrrX57pxYwksF3PpTwLKmEPITvTnot6oR hIz0qVyXhYmC8k6OIwo1Ynn3LAkO7U+opNeGp6fUF8uWcvjIGOv7TooPzuAIszMPk4uX MMBbAnQzUcPFb1GqsqKaCujKMvgKuNlg2Myy1LaDyfROqZ4FmjEB6xAxsVpQRuVXH2rn nQkgJjxx4iDZleYOToRZpxTL4GABP3FWuj7egMSsxortyXe7InhG3pj0HrM3yJhsEXRR M2kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724343690; x=1724948490; 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=WaN7NC9uHrEwXd29tH1+I6/CGeGFysWI1W1y0Mcbdjo=; b=udq4o3PuCMJ03ZAM077evkoeY5O7Sl3mo2pevVfPJuzCM4hnJ1fcYX2v18okJY7fjK +FmIrtsVfRUnOK/rJDUGjl3IuNSgX+YU8L73TbatPuAepaPISalpzffG/gIaQvQe1EAL +gww/xd+iB1hzhlbhjEgHG2emlVkV/MAcFEG35INriX9fOICVSet0ZJC+0rNnA/Fu0K5 nrWYfaqEPfWZxRe31lHWDM1g4q/eOHt82Y34tVDX6dRO/IDlsOdo7fC4p2skSF/RpbE5 BUmTNAq/OQG214+rp4er+Yhu8dYTrmJDBnaz73+icmzSUZ+XqfDRduGgX5bYc28lE5or Dg9A== X-Forwarded-Encrypted: i=1; AJvYcCWcLYKpjCMgu6q49y7GNGXLQFQe0FLJwBHow1TPrCHDX4rZmTGzzGbnwO0bnGowQJ5LEANSyB2W4Uz9@nongnu.org X-Gm-Message-State: AOJu0YwGhgtu95vrE0jw1zkU6BCCPhHW6YoURFyH4UmZegAFm6eHuL3b KvwfFMGaAgr71s8nhHul0H3FmoAhrJ6nIlZui8dDrV2ZSODAxLZCoUfBviicyZ0= X-Received: by 2002:a05:6000:1087:b0:368:5a8c:580b with SMTP id ffacd0b85a97d-37308c1809emr1629814f8f.19.1724343689838; Thu, 22 Aug 2024 09:21:29 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm28928485e9.23.2024.08.22.09.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:21:29 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Alistair Francis , "Edgar E. Iglesias" , Francisco Iglesias Subject: [PATCH for-9.2 1/6] hw/misc/xlnx-versal-cfu: destroy fifo in finalize Date: Thu, 22 Aug 2024 17:21:22 +0100 Message-Id: <20240822162127.705879-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822162127.705879-1-peter.maydell@linaro.org> References: <20240822162127.705879-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Since the TYPE_XNLX_VERSAL_CFU_FDRO device creates a FIFO in its instance_init method, we must destroy the FIFO in instance_finalize to avoid a memory leak for the QOM introspection "instantiate-examine-finalize" cycle: Direct leak of 8192 byte(s) in 1 object(s) allocated from: #0 0x55ec89eae7ee in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-aarch64+0x294d7ee) (BuildId: 6d508874816cc47d17c8dd775e8f809ae520e8cb) #1 0x7f697018f738 in g_malloc debian/build/deb/../../../glib/gmem.c:128:13 #2 0x55ec8d98d98d in fifo8_create util/fifo8.c:27:18 #3 0x55ec8aa2a624 in fifo32_create /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/include/qemu/fifo32.h:35:5 #4 0x55ec8aa2a33c in cfu_fdro_init hw/misc/xlnx-versal-cfu.c:397:5 #5 0x55ec8ce75da1 in object_init_with_type qom/object.c:420:9 #6 0x55ec8ce5d07b in object_initialize_with_type qom/object.c:562:5 #7 0x55ec8ce5e91d in object_new_with_type qom/object.c:782:5 #8 0x55ec8ce5e9f1 in object_new qom/object.c:797:12 #9 0x55ec8d65c81d in qmp_device_list_properties qom/qom-qmp-cmds.c:144:11 Signed-off-by: Peter Maydell Reviewed-by: Francisco Iglesias Reviewed-by: Alistair Francis --- hw/misc/xlnx-versal-cfu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/misc/xlnx-versal-cfu.c b/hw/misc/xlnx-versal-cfu.c index 6bb82e51c15..2284b407eab 100644 --- a/hw/misc/xlnx-versal-cfu.c +++ b/hw/misc/xlnx-versal-cfu.c @@ -397,6 +397,13 @@ static void cfu_fdro_init(Object *obj) fifo32_create(&s->fdro_data, 8 * KiB / sizeof(uint32_t)); } +static void cfu_fdro_finalize(Object *obj) +{ + XlnxVersalCFUFDRO *s = XLNX_VERSAL_CFU_FDRO(obj); + + fifo32_destroy(&s->fdro_data); +} + static void cfu_fdro_reset_enter(Object *obj, ResetType type) { XlnxVersalCFUFDRO *s = XLNX_VERSAL_CFU_FDRO(obj); @@ -539,6 +546,7 @@ static const TypeInfo cfu_fdro_info = { .instance_size = sizeof(XlnxVersalCFUFDRO), .class_init = cfu_fdro_class_init, .instance_init = cfu_fdro_init, + .instance_finalize = cfu_fdro_finalize, .interfaces = (InterfaceInfo[]) { { TYPE_XLNX_CFI_IF }, { } From patchwork Thu Aug 22 16:21:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 821334 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp1268387wrm; Thu, 22 Aug 2024 09:22:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUwEjRPrfCKqgoaz5+3wGGvrcCGuRrLDpNb+xF7jNWnKSqdiKMlkmcyXhhtCbhqy6QQ17fDww==@linaro.org X-Google-Smtp-Source: AGHT+IGDm4tSIDD8MTFErkwmCODRol7msDXaWcJEWKerPwapxdfcmJpkpNSUmAwo6B3CzI3LvH8n X-Received: by 2002:a05:6358:7252:b0:1aa:c71e:2b4d with SMTP id e5c5f4694b2df-1b5b3a91332mr277903055d.20.1724343779513; Thu, 22 Aug 2024 09:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724343779; cv=none; d=google.com; s=arc-20160816; b=RUS/q0HBqgYD4g80jSTY0B2xNf3hhXskEXD7xME6ASlODdXBxtT/xdU8sK0X0AClUM InwMqBcgaXRBr64BcDyv/XCzw2CCXmx4ldc7yMkFygsDo1RG8YfNV4d/wht9tb+eD+24 YWmBJm1048YZrICa3PWNRmiEcL0eGYnJ0nYzGkaB6uGYT5dW8LKyNptvckX2QS8ira4E pDIWydPsvNUq5nz8DI7w9lD/UuG3JZEpKUam8B2OKDhJwbci+XP9GWlCLl7ZcTyEZZ44 nMNkUNDKekPnhYvxqNIeCy3BZfsshDTBOHEG8klCoTZ6thLvfykQyuE9SVV8QJTD3MBn /F7g== 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=rRIh29OU7dNzm5XtXlrEQk7GPVofTkxU59XhpGGv5/A=; fh=hsiZh6z6VL+K4CvpaUQuXHcVxoA2TLjwNmkcb4IzG1o=; b=CTJSyv963t/yV4zfo11miObMgUcfq/r2eAO5ce5boDnY57TriLWxbhZHLO1FQzR1Ts TN1AMQpEQh7+aSVPgd8wgfn6YagnlwIR9Yxw6lzKP18tQ1J92K/xQM2H3w63NJjFr5I7 kCvH6bP8pvgHZJ0HG9X1aMS9a0RvJD5m9vIuTSSHaCyD4V2LY44Tk264N5Dm2Zux9BHU 5TPdrK+a8+bsblZfZ9ZmvRuLaoDayQzToZvQLKdmjoI1r2VH+zaaRuxB2BTnRB0O6kuK Sg+cnnUJnndc3ZlByxl83iMUfgI1Ip3ZSE3+urZlD8hYAyEF7mhkKK7BBDdvx33d+edH YAGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Aqig05m1; 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 71dfb90a1353d-4fd0832d05csi485964e0c.156.2024.08.22.09.22.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2024 09:22:59 -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=Aqig05m1; 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 1shAZN-0005id-3M; Thu, 22 Aug 2024 12:21:53 -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 1shAZD-000575-FW for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:43 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shAZ4-0007K9-5m for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:38 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42816ca782dso7484165e9.2 for ; Thu, 22 Aug 2024 09:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724343690; x=1724948490; 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=rRIh29OU7dNzm5XtXlrEQk7GPVofTkxU59XhpGGv5/A=; b=Aqig05m1LszCefa1p+WpMvLPgGz1e5vPghRll6xMHoUz/EcDSOHpEkHL5YXl0DWz8J lAvmMzzQHJw1xwV+nNoLXBZfFPcgwo54r24WYpH8HDvqMvobF61/5k76TlqueBfGeQoe vJ70y2R6GY0vN1Vx20sKPMKbq2j83IpZUWTa6LrJl2YKEb4zB9pGb26JHprUu2gnpsEQ 5PhTGKwFsn3Ltb4i/IZy5vzeRq94dMZ332SqXE6T6IuOdAVBT/VMriwg8qD/zxDdeSMA NDAmiZZXX/XEm4i/GYR13oPTN4FIB+ZiYhc4CEaGHuyIum4q6Y+sA6lz8PJ5tKNHDAMU KwTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724343690; x=1724948490; 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=rRIh29OU7dNzm5XtXlrEQk7GPVofTkxU59XhpGGv5/A=; b=UCDWTRi6pH/1Dy62WSMN+xlX1lY1jXoZAfcK5/9ROtMTAlAcmYbrPaAUZqlJii22nQ uv8whvY/XBPdym+CON/65PQtQRnbc7KM76lS4AHCClAWcAUU4eUM1nVzU1qfwxUoUAgM EU3sX2dVwxy1JdkUOmcjCneiZOmhYmUHJOlsRYUHjdPc4F1BPPRp/cP1HGxyziVjFO+0 pIDCuM/JU2YojnO+hEp54uyIYfQLweCbEfMv543UJmmxdy0z11EdqHLyyZVmfrG3ifc1 894bzwpnBUvNvYET9UGiL/KkSGux1b6MqFGTi9cSlFqaswL1CgJgSMtSee4YQymkPFSi gXdg== X-Forwarded-Encrypted: i=1; AJvYcCW3ol+XsMMDThZOzC2yxjQWfABilIVpaVZyRV7xrzHIE6DFCVS+Xvtijbq0DYpaVWCm0PArGeq4ixBS@nongnu.org X-Gm-Message-State: AOJu0Yxjjw5ADQkCGqqiPPvzNayvsdEJTgUD0vgxYO2elZR0Xc6DpMSy LUYdsxTYzVhyeWxGeR9al6Rweh0/cC31tGpIZFacZku5pJG4qMDw7ehEjg2y0qk= X-Received: by 2002:a05:600c:1992:b0:426:6ee7:c05a with SMTP id 5b1f17b1804b1-42abd23061amr43199385e9.15.1724343690325; Thu, 22 Aug 2024 09:21:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm28928485e9.23.2024.08.22.09.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:21:30 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Alistair Francis , "Edgar E. Iglesias" , Francisco Iglesias Subject: [PATCH for-9.2 2/6] hw/misc/xlnx-versal-trng: Free s->prng in finalize, not unrealize Date: Thu, 22 Aug 2024 17:21:23 +0100 Message-Id: <20240822162127.705879-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822162127.705879-1-peter.maydell@linaro.org> References: <20240822162127.705879-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The TYPE_XLNX_VERSAL_TRNG device creates s->prng with g_rand_new() in its init method, but it frees it in its unrealize method. This results in a leak in the QOM introspection "initialize-inspect-finalize" lifecycle: Direct leak of 2500 byte(s) in 1 object(s) allocated from: #0 0x55ec89eae9d8 in __interceptor_calloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-aarch64+0x294d9d8) (BuildId: 6d5 08874816cc47d17c8dd775e8f809ae520e8cb) #1 0x7f697018fc50 in g_malloc0 debian/build/deb/../../../glib/gmem.c:161:13 #2 0x7f6970197738 in g_rand_new_with_seed_array debian/build/deb/../../../glib/grand.c:202:17 #3 0x7f6970197816 in g_rand_new debian/build/deb/../../../glib/grand.c:286:10 #4 0x55ec8aa3656a in trng_init hw/misc/xlnx-versal-trng.c:624:15 #5 0x55ec8ce75da1 in object_init_with_type qom/object.c:420:9 #6 0x55ec8ce5d07b in object_initialize_with_type qom/object.c:562:5 #7 0x55ec8ce5e91d in object_new_with_type qom/object.c:782:5 #8 0x55ec8ce5e9f1 in object_new qom/object.c:797:12 #9 0x55ec8d65c81d in qmp_device_list_properties qom/qom-qmp-cmds.c:144:11 Move the free to finalize so it matches where we are initing s->prng. Since that's the only thing our unrealize method was doing, this essentially switches the whole function to be a finalize implementation. Signed-off-by: Peter Maydell Reviewed-by: Alistair Francis --- hw/misc/xlnx-versal-trng.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/misc/xlnx-versal-trng.c b/hw/misc/xlnx-versal-trng.c index 51eb7600414..c0d1dde8708 100644 --- a/hw/misc/xlnx-versal-trng.c +++ b/hw/misc/xlnx-versal-trng.c @@ -624,9 +624,9 @@ static void trng_init(Object *obj) s->prng = g_rand_new(); } -static void trng_unrealize(DeviceState *dev) +static void trng_finalize(Object *obj) { - XlnxVersalTRng *s = XLNX_VERSAL_TRNG(dev); + XlnxVersalTRng *s = XLNX_VERSAL_TRNG(obj); g_rand_free(s->prng); s->prng = NULL; @@ -689,7 +689,6 @@ static void trng_class_init(ObjectClass *klass, void *data) ResettableClass *rc = RESETTABLE_CLASS(klass); dc->vmsd = &vmstate_trng; - dc->unrealize = trng_unrealize; rc->phases.hold = trng_reset_hold; /* Clone uint64 property with set allowed after realized */ @@ -706,6 +705,7 @@ static const TypeInfo trng_info = { .instance_size = sizeof(XlnxVersalTRng), .class_init = trng_class_init, .instance_init = trng_init, + .instance_finalize = trng_finalize, }; static void trng_register_types(void) From patchwork Thu Aug 22 16:21:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 821337 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp1268445wrm; Thu, 22 Aug 2024 09:23:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUUYmGmOvUsFF4acTeCbAI3LCgIIWt69/EHT4JMqm/Lezbx3Qnotd7BgvzK/4ceNTTp/Xkgug==@linaro.org X-Google-Smtp-Source: AGHT+IE8pkKcWTkfhRLxGV/Rn61pPpu+jHch+1JFzNMa5lqMKcMjjXB3XMcyaX+xNdW293l40M+N X-Received: by 2002:a05:6358:6f17:b0:199:2942:1b32 with SMTP id e5c5f4694b2df-1b5a2869cc5mr786842755d.8.1724343786563; Thu, 22 Aug 2024 09:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724343786; cv=none; d=google.com; s=arc-20160816; b=bsJOKyJQzs+fGoCYNq4gehuQmbwVpRh6WE9DipWOtrDdQI2Y86u000tnddLoDgb8sn LpmU975FsFrM9NVO3+F8EYWRXHjve8TLTNRDs3wHzUkAK1lKL3lz0NUB04yucg4DSM/x SP9eiY2zocrkeygMuH91B1ciZShX40ZeHOCWicxWdla5Ys89ofY2E0gc4ETCTbT3rzpg oh4oTgsaImqIKZBjC0ztaJPyFLqinahKokI5TbstXqH1BszRgUqUFpThFc22buHMajqO 4hHQwWswckLGCTL4Bh8v6thjvCd4hiLXjFX5GoTopmkw4K9Av8MUaPXygNOWrgxpB+nE OTmA== 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=pKFPg971wT4+RsKvDlNvV4P8wQdSeCeiTzH4yTjPvqA=; fh=wBk37iEhLwdOP9Z9ucm6kYDFTXGDXutXWSi3I9hskMc=; b=PZk0RKOyZhOn9hglmSa71EnPeF0wFki7OuQ+yBL/gbolmbWRk/v3ry5x81NOsDoEjE 2BUJHS/jcYYbq4FBdjX5aDXh0/aFdQk5SZMlNtl7Yh49kl8uYIjPRWlv5BhiKa7MeBP+ 30JlIOJZZ3fIF7zCBTp4cOGtmahhvZ8duiTyjZu+71rD5c6THCR8GgSODQqC+TMVyumz fT+LrYXeO9WweG1AfJp2NUPikZDxxBbVPiY8nlsri6XEmVLM6HrQEnhnBcUPTJgANwcW QfonuuuO5aoCnDSUTLod6qTGiq8zbD8Z+k3a4gRzwj6A2+uWx8vZNeTdvs8tr3mpTBIq e5Tg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m8LzL14j; 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 ada2fe7eead31-498e48de22asi440127137.338.2024.08.22.09.23.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2024 09:23: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=m8LzL14j; 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 1shAZD-00055X-5g; Thu, 22 Aug 2024 12:21:43 -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 1shAZ7-0004uj-Tv for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:37 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shAZ3-0007KI-UX for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:37 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-429e29933aaso7303365e9.0 for ; Thu, 22 Aug 2024 09:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724343691; x=1724948491; 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=pKFPg971wT4+RsKvDlNvV4P8wQdSeCeiTzH4yTjPvqA=; b=m8LzL14jTglIPWyO8tU0YGKVSms4gUkX8TaOuM9icyoLuzAb9bguudKLDm3OkHdGI5 hvYJsUSkPb2VEzfUHslck1ar2q6HtRG8+tMlh3P4KQkmDCQJfg1MjHdBLX34KGJdFx2l CevoX+6EPBl7GudgkhAoP1Omr+sfrzxiFwScG29zvsufnu/BG+3/QDVZQdvwMVFB3ra9 +Tym4a8w6mtDQFNNzA88Yy8u125VKqAwYeEN3IZHFv69qZUNGdYsFkexW1/zmc7Z/3A+ Ts+j5WonZBW16ZR9BsvJrhxnstxmbUGB8Kz+n3Bw1zKyKi/+Nrg+3XawysQyO6g6llJ/ 0dsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724343691; x=1724948491; 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=pKFPg971wT4+RsKvDlNvV4P8wQdSeCeiTzH4yTjPvqA=; b=iEsTmFRpznreRC447pRC7wZlNB/LNFpj73zLafWRVFrry2EBctsvqtj8OmVIXN4LdZ SwMxkk2DoLzw/LdT657SLCTYPw0GXae8ykfrjeJqolMsnMW16scmTF90iDVnAq1NFkD2 yA/YFuTyM3kYUmFRv0ij7WU7Sexh6rpJ2OJ54sBn69QSiE0RnRsnM2JtRsHs4TDBuSVA kosJtMoUS1UNDRduFlGwpRYT/4NlM3uxnJ3zXG3gPn8CCImOU7BO1Ap6Z/QSqQEGFxhw qzMA0fwCkZI0rd79jYgH17bba7N+UvMCxxwaUUPIrS1MUOzna9ZkYLbH44+YHeSLh78U ilVQ== X-Forwarded-Encrypted: i=1; AJvYcCW19WUIO4e7iiJX0QmXI9YZFBIJRAmE9VKAt3mUol8p3zFhny6txWwVVXmfcI5HLLYxPysNBAwWrwEd@nongnu.org X-Gm-Message-State: AOJu0YxzS3ZdQdfD4kN5iuN01P9um8ByUDUHMd+ZhClC7t2F0DR07azt /RBffp+kDwbKe3RhZkF0qxwsStOQX9xeAwHzddfrDw5rijFJY9KUDl5cqBsZvsI= X-Received: by 2002:a05:600c:4e8f:b0:426:59ad:bbb3 with SMTP id 5b1f17b1804b1-42ac564ef4bmr19280605e9.32.1724343690904; Thu, 22 Aug 2024 09:21:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm28928485e9.23.2024.08.22.09.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:21:30 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Alistair Francis , "Edgar E. Iglesias" , Francisco Iglesias Subject: [PATCH for-9.2 3/6] hw/nvram/xlnx-bbram: Call register_finalize_block Date: Thu, 22 Aug 2024 17:21:24 +0100 Message-Id: <20240822162127.705879-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822162127.705879-1-peter.maydell@linaro.org> References: <20240822162127.705879-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The TYPE_XLNX_BBRAM device creates a register block with register_init_block32() in its instance_init method; we must therefore destroy it in our instance_finalize method to avoid a leak in the QOM introspection "init-inspect-finalize" lifecycle: Direct leak of 304 byte(s) in 1 object(s) allocated from: #0 0x5641518ca9d8 in __interceptor_calloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-aarch64+0x294d9d8) (BuildId: 4a6 18cb63d57d5a19ed45cfc262b08da47eaafe5) #1 0x7ff1aab31c50 in g_malloc0 debian/build/deb/../../../glib/gmem.c:161:13 #2 0x564151cffc5d in register_init_block hw/core/register.c:248:34 #3 0x564151d006be in register_init_block32 hw/core/register.c:299:12 #4 0x56415293df75 in bbram_ctrl_init hw/nvram/xlnx-bbram.c:462:9 #5 0x564154891dc1 in object_init_with_type qom/object.c:420:9 #6 0x56415487909b in object_initialize_with_type qom/object.c:562:5 #7 0x56415487a93d in object_new_with_type qom/object.c:782:5 #8 0x56415487aa11 in object_new qom/object.c:797:12 #9 0x56415507883d in qmp_device_list_properties qom/qom-qmp-cmds.c:144:11 Signed-off-by: Peter Maydell Reviewed-by: Francisco Iglesias Reviewed-by: Alistair Francis --- include/hw/nvram/xlnx-bbram.h | 1 + hw/nvram/xlnx-bbram.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/hw/nvram/xlnx-bbram.h b/include/hw/nvram/xlnx-bbram.h index 6fc13f8cc17..bce8e89d905 100644 --- a/include/hw/nvram/xlnx-bbram.h +++ b/include/hw/nvram/xlnx-bbram.h @@ -47,6 +47,7 @@ struct XlnxBBRam { bool bbram8_wo; bool blk_ro; + RegisterInfoArray *reg_array; uint32_t regs[RMAX_XLNX_BBRAM]; RegisterInfo regs_info[RMAX_XLNX_BBRAM]; }; diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c index 09575a77d77..1bc58e90ad0 100644 --- a/hw/nvram/xlnx-bbram.c +++ b/hw/nvram/xlnx-bbram.c @@ -456,9 +456,8 @@ static void bbram_ctrl_init(Object *obj) { XlnxBBRam *s = XLNX_BBRAM(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - RegisterInfoArray *reg_array; - reg_array = + s->reg_array = register_init_block32(DEVICE(obj), bbram_ctrl_regs_info, ARRAY_SIZE(bbram_ctrl_regs_info), s->regs_info, s->regs, @@ -466,10 +465,17 @@ static void bbram_ctrl_init(Object *obj) XLNX_BBRAM_ERR_DEBUG, R_MAX * 4); - sysbus_init_mmio(sbd, ®_array->mem); + sysbus_init_mmio(sbd, &s->reg_array->mem); sysbus_init_irq(sbd, &s->irq_bbram); } +static void bbram_ctrl_finalize(Object *obj) +{ + XlnxBBRam *s = XLNX_BBRAM(obj); + + register_finalize_block(s->reg_array); +} + static void bbram_prop_set_drive(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -537,6 +543,7 @@ static const TypeInfo bbram_ctrl_info = { .instance_size = sizeof(XlnxBBRam), .class_init = bbram_ctrl_class_init, .instance_init = bbram_ctrl_init, + .instance_finalize = bbram_ctrl_finalize, }; static void bbram_ctrl_register_types(void) From patchwork Thu Aug 22 16:21:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 821333 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp1268384wrm; Thu, 22 Aug 2024 09:22:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWq8EkIvCe7tVLoAOgsMIwJndmkXurxmpiQ+LdEIu+T8y278FiKztsk0rDN2Sy125Q925yRwA==@linaro.org X-Google-Smtp-Source: AGHT+IH46nq62nttTJViQUmUnjrYuVJuZO3D15q37au93xTb4ZFIZVzS3ImR0kmcfJN+J+0G7i4k X-Received: by 2002:ac8:5f93:0:b0:442:1bdc:2a6 with SMTP id d75a77b69052e-454faf059efmr54214541cf.30.1724343779203; Thu, 22 Aug 2024 09:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724343779; cv=none; d=google.com; s=arc-20160816; b=dxityPOS4jW+DFiLJ/hH1I02WoZC79QJIXxICkm5oN5LfUJqFEETTEcJytH9sRmUNR lsJweLBboRrUAp0mzyyhW97v0MZSgPk+zO5fm6mak0rXZDCvkDNueJ7YETtCjbB7NtE4 XcqVtGDAco1wgXo3ifgUydgBykYUSsz2cDcENm71bDgJEH0mUypcXCf6oucNNUGFghGA kMB8O9cUaGgiOgZxNjpR3Cgz8lOZ3f1pJsavz8aNVbwcOMZmWWq3Ync3D5xRoOKxJttV iQc5KsHM2RMCGsmramx8+sAA8H99P01XgL8X29yMj9ehiWLE2+nNZ3K5zwoqKII4OWm2 HRYg== 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=Q9APIXuRLkKIat+l/rZBodPQDnkc/ZwrT5ldPMm81wI=; fh=ZJIz2mDHet4r7y31NoabOsTJQ7ANrHJikptrC4LgUL8=; b=kNSh+6vxQ63xGC5CDUA2PtttzRrZhQwAHxyr1FsYcnitamtnZEaukKGq5WgciZADQA ZT8UbiwJOSf8tNWYTqMI//2c4TZQwcdCq+R4seepsJesp02DPZW+72UaQEgJjYL1QFXD JVHQdmR5HsUQemXxcAS6RCNL5n/ZXRj+WnUwpQY8Qh+iOqHYv/L2Uc+7PkeUWmHhWaAU ku9Gx0rxP45ceXmyfJYqEWldY9Qvpzc1itwN8533uD+YbklCKM3GikrHyVOMa28jyYmO 3LMcbEvBI7AVDiNwe/AmNQEDWTi7fK7sHGW0KhKima00cltf/b/zyq5VnOETH0olCvWf hDug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dX4gtxa/"; 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 d75a77b69052e-454fe322c78si17991261cf.589.2024.08.22.09.22.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2024 09:22:59 -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="dX4gtxa/"; 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 1shAZI-0005NF-Uy; Thu, 22 Aug 2024 12:21:49 -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 1shAZD-00057L-HE for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:43 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shAZ5-0007KV-Mb for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:39 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4281c164408so7307915e9.1 for ; Thu, 22 Aug 2024 09:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724343691; x=1724948491; 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=Q9APIXuRLkKIat+l/rZBodPQDnkc/ZwrT5ldPMm81wI=; b=dX4gtxa/fE4qo5Yt/TAdeYUd7Vjyz0nqR61MVZ1qxEvUR3bL4GEkbeyCi87HXiUd+H TtMHy/UYwqbJXDg7IOSe6U6vNVFXb2TAidq5nNjtKLteP/Gzs+SUs8x3zDtiQBAp4t/9 EWMKVti032LHS8tN+s0UC2WPiJ/F/tW9vVZNXbNmLyeSMBjH7ryKl/7AvU77RG+xCaLb hd0kHxDd2Q6eb3ALBMIaWhg1PB+8bRe37UkMqIsNd1DJXz0bJuVjItxbjwFThssoL5GF sigcwKwK3DwDlV7WSekiKfVzDwtd7NZsgAZKJXvPFC0Mn6Mb52zgZlKV38Mp7bxHHZ22 VGYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724343691; x=1724948491; 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=Q9APIXuRLkKIat+l/rZBodPQDnkc/ZwrT5ldPMm81wI=; b=iH9xD9XPsOmr5bWaAmUTlERpqCQ1STczNXAZPxSJeHxB0iMi3Cb/l+w3YiRsuRohWA HlRe6zaevOKvEdT/9sxnGMy2jKLd1MwlIcC8fvxTjni74BADFLfsVgydYRPjli7787pt Dv5FikeGJaXSrQ6WzFwwsx3dIi7vFLiR+8HXLeVt2KgmK0IhTtBFCf57JnqIa4uWoWWi v4KLe2Jr6r+0E/Z/SgAUSF4Mcf3BEDbU4VL3JXMQzH68O6a6IY6p1PeAAkq5rWONdEPt ph9D/fYAxZpG3ZFC09p/m8zSm032cNatVBKzTJrSf+iWayQhRzYgrlZNCmS25s0F5uB1 MayQ== X-Forwarded-Encrypted: i=1; AJvYcCX5tSQi+GpE0dh1/he6WUXeWgYrn5QhGL9TVqyfEJTDSu07TMT2y9Kc2wWAw7kwTFV7CsFYNdIGObgD@nongnu.org X-Gm-Message-State: AOJu0YxC44+xLVZif2bnWvq0PPeYtcG6d7GOGiskG6uaOH0FvBGr9yAP 9OAXSL9pRqkb8uQSwh/+h5IoICdnvJwef76YKnSUwVrfPbu006sIn65sEQd4Zm4= X-Received: by 2002:a05:600c:1c90:b0:426:647b:1bfc with SMTP id 5b1f17b1804b1-42abd244b11mr38979685e9.30.1724343691475; Thu, 22 Aug 2024 09:21:31 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm28928485e9.23.2024.08.22.09.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:21:31 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Alistair Francis , "Edgar E. Iglesias" , Francisco Iglesias Subject: [PATCH for-9.2 4/6] hw/nvram/xlnx-zynqmp-efuse: Call register_finalize_block Date: Thu, 22 Aug 2024 17:21:25 +0100 Message-Id: <20240822162127.705879-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822162127.705879-1-peter.maydell@linaro.org> References: <20240822162127.705879-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The TYPE_XLNX_ZYNQMP_EFUSE device creates a register block with register_init_block32() in its instance_init method; we must therefore destroy it in our instance_finalize method to avoid a leak in the QOM introspection "init-inspect-finalize" lifecycle: Direct leak of 304 byte(s) in 1 object(s) allocated from: #0 0x55f3ff5839d8 in __interceptor_calloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-aarch64+0x294d9d8) (BuildId: 23cf931c66865a71b6cc4da95156d03bc106fa72) #1 0x7f3f31c6bc50 in g_malloc0 debian/build/deb/../../../glib/gmem.c:161:13 #2 0x55f3ff9b8c5d in register_init_block hw/core/register.c:248:34 #3 0x55f3ff9b96be in register_init_block32 hw/core/register.c:299:12 #4 0x55f4005e5b25 in efuse_ctrl_init hw/nvram/xlnx-versal-efuse-ctrl.c:718:9 #5 0x55f40254afb1 in object_init_with_type qom/object.c:420:9 #6 0x55f40253228b in object_initialize_with_type qom/object.c:562:5 #7 0x55f402533b2d in object_new_with_type qom/object.c:782:5 #8 0x55f402533c01 in object_new qom/object.c:797:12 #9 0x55f402d31a2d in qmp_device_list_properties qom/qom-qmp-cmds.c:144:11 Signed-off-by: Peter Maydell Reviewed-by: Francisco Iglesias Reviewed-by: Alistair Francis --- include/hw/nvram/xlnx-zynqmp-efuse.h | 1 + hw/nvram/xlnx-zynqmp-efuse.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/hw/nvram/xlnx-zynqmp-efuse.h b/include/hw/nvram/xlnx-zynqmp-efuse.h index f5beacc2e6a..7fb12df3fbb 100644 --- a/include/hw/nvram/xlnx-zynqmp-efuse.h +++ b/include/hw/nvram/xlnx-zynqmp-efuse.h @@ -37,6 +37,7 @@ struct XlnxZynqMPEFuse { qemu_irq irq; XlnxEFuse *efuse; + RegisterInfoArray *reg_array; uint32_t regs[XLNX_ZYNQMP_EFUSE_R_MAX]; RegisterInfo regs_info[XLNX_ZYNQMP_EFUSE_R_MAX]; }; diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c index 2d465f0fc6a..4e2d1b9d1e7 100644 --- a/hw/nvram/xlnx-zynqmp-efuse.c +++ b/hw/nvram/xlnx-zynqmp-efuse.c @@ -803,9 +803,8 @@ static void zynqmp_efuse_init(Object *obj) { XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - RegisterInfoArray *reg_array; - reg_array = + s->reg_array = register_init_block32(DEVICE(obj), zynqmp_efuse_regs_info, ARRAY_SIZE(zynqmp_efuse_regs_info), s->regs_info, s->regs, @@ -813,10 +812,17 @@ static void zynqmp_efuse_init(Object *obj) ZYNQMP_EFUSE_ERR_DEBUG, R_MAX * 4); - sysbus_init_mmio(sbd, ®_array->mem); + sysbus_init_mmio(sbd, &s->reg_array->mem); sysbus_init_irq(sbd, &s->irq); } +static void zynqmp_efuse_finalize(Object *obj) +{ + XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj); + + register_finalize_block(s->reg_array); +} + static const VMStateDescription vmstate_efuse = { .name = TYPE_XLNX_ZYNQMP_EFUSE, .version_id = 1, @@ -853,6 +859,7 @@ static const TypeInfo efuse_info = { .instance_size = sizeof(XlnxZynqMPEFuse), .class_init = zynqmp_efuse_class_init, .instance_init = zynqmp_efuse_init, + .instance_finalize = zynqmp_efuse_finalize, }; static void efuse_register_types(void) From patchwork Thu Aug 22 16:21:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 821335 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp1268394wrm; Thu, 22 Aug 2024 09:23:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXHO9d1w0iF5qXMJ4w5uSEOh4klAAOOYDIzPZQ17y+9f2vgajXKVrgSxWFBQUfjulpaYSnX9g==@linaro.org X-Google-Smtp-Source: AGHT+IEwlGD+QgQSFoiw0yn/RkvDZ7nJMWaZ27u8yhWv0TrRqkmCbXDf7auuf2z7X6RLUArCTILm X-Received: by 2002:a05:6358:9216:b0:1ad:b237:1b7e with SMTP id e5c5f4694b2df-1b59fc6f404mr707943055d.30.1724343780181; Thu, 22 Aug 2024 09:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724343780; cv=none; d=google.com; s=arc-20160816; b=GGJqdrq6T/Yr4ouRPrscnIurO6quc2hpuUi+2pIEB6DziivQOM81A74/DKdShsqlWz 3xGDqpMgSg+xho/z45EXyTUXHEvdV43+B3jOQ9V8FkCVy9ScBwl8fEjIoKPpLJTqKSsc bYMpFdw9SHEu8zHw1cpONW/+MiVKMDNDuYjQt5Y3L2hQHjvt68H6pkrsZgbuiarZpZjQ /Q1yDDPU01rt/+pwIjuFdX/PhAeddOaAY5i+W9jZz6Y/npDMM/en00OQgfO4s5v2L/nJ 8BVz+vtRWinfJJEUVDh0LlDyVVvBocXmfjZz43LQGYkc5aT1cilsOx2St0qhGwhAgwms n6kQ== 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=nMpLWn3WW/z8gsXVfqO2IPBe/rQMV7r1aFvdjBG7Zt4=; fh=RZBbxREEwXda0teXtZJZt20AI1QcJLLfH9xm2nc9i7M=; b=i/7QwAyS0SYkDUU7yiZoMBFAvI9NhDR2rQxXvej3VWbAq7GJh2nAWmNdxYFA/yJJrU NZdtFgKwEEdutZzOBDHywj0V1utNSsEI+VJt1p4PyJXaoEQmwmlSBDCsclGt9hDTNzud 0POiF7SwOBt/he7v7ZQj/hsD9nZNCAPryyOI0hwp82Ktc0Y0SJ1o4s/Xmau+FaxzeOyW 9syVY+4Jg29svMOtgD13Sf3lpAn2qqIq1fAFyohNx8+RQypu8t0PgCi7g5924zT+qi0l FGgKbVYnx92CsrZVbn33Ce+ig98L61ELEaZQmil5qQmwYKR5hm6C8UtTXH9qa50RTQc5 6UGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uO3W1+td; 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 a1e0cc1a2514c-844ce565741si423744241.108.2024.08.22.09.23.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2024 09:23:00 -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=uO3W1+td; 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 1shAZH-0005MH-44; Thu, 22 Aug 2024 12:21: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 1shAZD-00057g-KE for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:43 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shAZ5-0007Ki-NO for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:41 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-37189d8e637so504262f8f.3 for ; Thu, 22 Aug 2024 09:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724343692; x=1724948492; 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=nMpLWn3WW/z8gsXVfqO2IPBe/rQMV7r1aFvdjBG7Zt4=; b=uO3W1+tdcqqKQy9b6fD3C0ArfnIs7RrGMYpNFQMEch/K3EijismlJK6YTAqPvcx4El F+Lp8vFMKrGEJYJj61z3puJ9yoHuuyCJa1LkoQanbBYWXiE+Mn2T+H1NM8E2Bv8K4gFm F6VDDMIxHpiRfFb1wdZo477CFcC0laLLTbJgiAVvzuowCGvv0+9ICFrGyHSUtXa3xvsv 49wsZmGzJWLF9ABqur6LH+4ITq8GbAtX0m8Xx+2LO51aT40b8ACbgOKm0rCGs70VRS52 1yfPYrdilfBX3nkdFj7P5nHLgGf3nL4mWPjaRKZReHllYqY0yfm4GgO6gxHC/vayHZGq yR6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724343692; x=1724948492; 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=nMpLWn3WW/z8gsXVfqO2IPBe/rQMV7r1aFvdjBG7Zt4=; b=xVn49sa2GyufLHIWP+Tdj/hMFzlsjb9w7ZnpcXxzjzc+2q3UP7eqP7Qpx03e/ryjqi ypUFdqrVeLxLdygT3GSvDbuex9Lb+fpE2rR8Ljl2qtBcZU/SOgps0bDlIgPiBhDVNm8U WhOTkz+87TQ/Vd+GxFIEBrOG6pfXy0WYuu73S4i0abttRYEdhc6EUWYbgTht2HEfQwNS g1GvOJC0WVn4joeyQ3NXG8zK/5r9rIuud3y0NjqkeWtkNlwpQfjkTYZwRaxDj/WZ8xYX IuZBgzF8Puorc+OuqCUqkOYk++FIRERjArlgeuJumOq+Xup+rsojpleRlrGwCb8b1a0b GNYA== X-Forwarded-Encrypted: i=1; AJvYcCWrHi3lINXrlv79syfSxr/wWinW7vgcICU0Yew3/QRTDNHf0z+7I8GKK4r4NiiNkT6pl8fCtlfvA2yV@nongnu.org X-Gm-Message-State: AOJu0YyhGuOib9zilu6ERSITyAdiwr52HN1M/o40EFZ/f4TUUdJVfWH+ alFFEyF1mFw5qLrAiP4iGhMffLGwah5/6rnmNo05zCoQ67C/PBh/tsSKarIbUpTJXUAWE7GRoq7 7 X-Received: by 2002:adf:e285:0:b0:368:31c7:19dd with SMTP id ffacd0b85a97d-37308bff403mr1437853f8f.5.1724343691981; Thu, 22 Aug 2024 09:21:31 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm28928485e9.23.2024.08.22.09.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:21:31 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Alistair Francis , "Edgar E. Iglesias" , Francisco Iglesias Subject: [PATCH for-9.2 5/6] hw/misc/xlnx-versal-trng: Call register_finalize_block Date: Thu, 22 Aug 2024 17:21:26 +0100 Message-Id: <20240822162127.705879-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822162127.705879-1-peter.maydell@linaro.org> References: <20240822162127.705879-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The TYPE_XLNX_VERSAL_TRNG device creates a register block with register_init_block32() in its instance_init method; we must therefore destroy it in our instance_finalize method to avoid a leak in the QOM introspection "init-inspect-finalize" lifecycle: Direct leak of 304 byte(s) in 1 object(s) allocated from: #0 0x55842ec799d8 in __interceptor_calloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-aarch64+0x294e9d8) (BuildId: 47496e53f3e779f1c7e9b82cbea07407152b498b) #1 0x7fe793c75c50 in g_malloc0 debian/build/deb/../../../glib/gmem.c:161:13 #2 0x55842f0aec5d in register_init_block hw/core/register.c:248:34 #3 0x55842f0af6be in register_init_block32 hw/core/register.c:299:12 #4 0x55842f801588 in trng_init hw/misc/xlnx-versal-trng.c:614:9 #5 0x558431c411a1 in object_init_with_type qom/object.c:420:9 #6 0x558431c2847b in object_initialize_with_type qom/object.c:562:5 #7 0x558431c29d1d in object_new_with_type qom/object.c:782:5 #8 0x558431c29df1 in object_new qom/object.c:797:12 #9 0x558432427c1d in qmp_device_list_properties qom/qom-qmp-cmds.c:144:11 Signed-off-by: Peter Maydell Reviewed-by: Francisco Iglesias Reviewed-by: Alistair Francis --- include/hw/misc/xlnx-versal-trng.h | 1 + hw/misc/xlnx-versal-trng.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/hw/misc/xlnx-versal-trng.h b/include/hw/misc/xlnx-versal-trng.h index 0bcef8a6132..d96f8f9eff3 100644 --- a/include/hw/misc/xlnx-versal-trng.h +++ b/include/hw/misc/xlnx-versal-trng.h @@ -50,6 +50,7 @@ typedef struct XlnxVersalTRng { uint64_t forced_prng_count; uint64_t tst_seed[2]; + RegisterInfoArray *reg_array; uint32_t regs[RMAX_XLNX_VERSAL_TRNG]; RegisterInfo regs_info[RMAX_XLNX_VERSAL_TRNG]; } XlnxVersalTRng; diff --git a/hw/misc/xlnx-versal-trng.c b/hw/misc/xlnx-versal-trng.c index c0d1dde8708..86905479b8f 100644 --- a/hw/misc/xlnx-versal-trng.c +++ b/hw/misc/xlnx-versal-trng.c @@ -608,9 +608,8 @@ static void trng_init(Object *obj) { XlnxVersalTRng *s = XLNX_VERSAL_TRNG(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - RegisterInfoArray *reg_array; - reg_array = + s->reg_array = register_init_block32(DEVICE(obj), trng_regs_info, ARRAY_SIZE(trng_regs_info), s->regs_info, s->regs, @@ -618,7 +617,7 @@ static void trng_init(Object *obj) XLNX_VERSAL_TRNG_ERR_DEBUG, R_MAX * 4); - sysbus_init_mmio(sbd, ®_array->mem); + sysbus_init_mmio(sbd, &s->reg_array->mem); sysbus_init_irq(sbd, &s->irq); s->prng = g_rand_new(); @@ -628,6 +627,7 @@ static void trng_finalize(Object *obj) { XlnxVersalTRng *s = XLNX_VERSAL_TRNG(obj); + register_finalize_block(s->reg_array); g_rand_free(s->prng); s->prng = NULL; } From patchwork Thu Aug 22 16:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 821336 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp1268413wrm; Thu, 22 Aug 2024 09:23:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVkLgX6ZJ/wzfKUDx+UMVsfljJj7kDDXjsLYAcUdFSVhqCLGIGYce6tnsAjlNqd1bS6h6vBhg==@linaro.org X-Google-Smtp-Source: AGHT+IFyH+uO1ySju/551/ggliFJCHJ9M6V58PwlQxAU0z2GwJ72w9saM9T3a3eR8YTUX8xRLgHS X-Received: by 2002:a05:620a:f07:b0:7a1:d69f:5b9c with SMTP id af79cd13be357-7a67d497da6mr771026485a.27.1724343782172; Thu, 22 Aug 2024 09:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724343782; cv=none; d=google.com; s=arc-20160816; b=cBIIIEQ+Ll+Q4LWPZ2pdVQEmFTyLlf0obANdIebq3VBxmc93o6PvY4PAysPEZA/TY/ 4ur2mu0cKSGrkIPMCEgmpnEexl81jjtcktiP37/l9TrBRKF1lTAoJMHFlipXjZsyChCC ZLMtIhSiAftAs2K0qPWwQaJee39tc78dFH21poe6JjN4gvILd56yVz+s4J2lXqdpCZXl LYNIdElFE6XnCus73nO6T5UzSI85yuyefQ32/K2JDgL/owZockf87aXBv3/ofp0ihNf8 cMkMZSQi1EeN6z8838YjWlLG7jHexY2fA8AVfzn/qzAZwKnJqrJabfcfZtgb3jmmfkSs Efgg== 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=AY1IW4T2DNcuGaXu8tbq///494SrbvPqRCnm6aioH7A=; fh=dtL+BIlMyesR170VSyTSnFp7zlGErZuU4f4ArKnxvoc=; b=rG4EzDKgFfuew+YEsjHqLKV4TXtUx12by1zC36aO+u3m7UYtl56F+HEKcBV0oSTken Uxne2dvrB3BgNtCjFw8oNNbpQZiv3EFk0+NpWqkmVn7OppPyglM1myoqOZMZwurcYFP+ jdb944tujGYv4CfcVCA79NjA9fVc+JkmvPvcWVXbY5mxwDDfFTvj/FEIr0T3YhafRYeH uC0z1QxuE6yvCAHcBpj0Y+uGM8JgbckSRTumYoawA1PoFQsKzupzX0j5lON1uu0ulXDM qVHo8naPbcc+wudAd3aPFZ4gIXp6epdfEPlY85BDTHZTMWdr1BLOS6TcUacHKuFAldLf jCjA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fl1OuYOW; 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-7a67f409320si185064485a.521.2024.08.22.09.23.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2024 09:23:02 -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=Fl1OuYOW; 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 1shAZN-0005iP-0N; Thu, 22 Aug 2024 12:21:53 -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 1shAZD-00057n-Kr for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:43 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shAZ7-0007Kr-JX for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:21:41 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42808071810so8020365e9.1 for ; Thu, 22 Aug 2024 09:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724343692; x=1724948492; 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=AY1IW4T2DNcuGaXu8tbq///494SrbvPqRCnm6aioH7A=; b=Fl1OuYOWFDeQlOlcI9XVmcXAxU309m/nzgchKo+6ZRffcwtUQgsljiJ6V8Oymsigw0 uKTvsbXz5si2DB52mBM8hFsfIIZRrhwagUS9/SCpQx9wEqxFzXhI1vYRsS2VF2QJ2EH9 0IIEs5DY/RByp97UQOrWANDntiTGlo1cuuTe1pqDTXboqhtJOMCZonUBA6jYLMWBoB4k qzQKO0UbLhdY59XZiLWNFWEOWxbk8TWZEekLbwuBm41iWOB1Vpf/VdbuSH+qicQjQf6O KCkcD3UErJN5bUoDzkbninizZndayvFaTZ4WZSlvqbAlaf2pu97ZGvuzP09avNtVlThS wdrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724343692; x=1724948492; 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=AY1IW4T2DNcuGaXu8tbq///494SrbvPqRCnm6aioH7A=; b=Ammk4tlhGhHwB/EV9XdUikByBdko7supaZ2jIwVcKI1EMlYaIpa8PM4saJfLEkQj/o 3hnlfwP1lBDNhmvGbB5JWYoCcbo6KNEmoIw6edRTiiaJB+8TN0HLUy68liW8ShGsC39E 2AFhyGqu7xti5lUbLUR2jcrikjozja0dC+6NjC6Yof6o8NpMMiBnf+8hiJOrNQIsl6ZV /8AnwXLBFmqHgJG25OhOpBP+y8qNm3EFQ3dPgQZTG9ExcxGEH78lgkZWuy5jk4QCi2AA 4f8venx1WOrgf3oUp/8d7GY+QIekFukMrG2WYlpd1YY1Uupul58UtLv4n1mchKWWxEAm /f9w== X-Forwarded-Encrypted: i=1; AJvYcCVHLbyLb6v8i/umffuvAj70UC1afXRxYEF2ynz980Is+MQ3SI9CgWHZ1nF/ZEx3QVYpORab5F/xvREW@nongnu.org X-Gm-Message-State: AOJu0YykQKyN7IvUJTnqraQy8ZTCVwDtWfhu5nfpLnyNMkt6qAsgyP/d IGuzMgRSAOzR17i5Ir1koPOxfqQCqV+OG8qdLnMBdHvRdbAyxLUWwJ1WfA4uAI8= X-Received: by 2002:a05:600c:468f:b0:426:68f2:4d7b with SMTP id 5b1f17b1804b1-42abd1121bbmr47556815e9.3.1724343692582; Thu, 22 Aug 2024 09:21:32 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm28928485e9.23.2024.08.22.09.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:21:32 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Alistair Francis , "Edgar E. Iglesias" , Francisco Iglesias Subject: [PATCH for-9.2 6/6] hm/nvram/xlnx-versal-efuse-ctrl: Call register_finalize_block Date: Thu, 22 Aug 2024 17:21:27 +0100 Message-Id: <20240822162127.705879-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822162127.705879-1-peter.maydell@linaro.org> References: <20240822162127.705879-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 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 The TYPE_XLNX_VERSAL_EFUSE_CTRL device creates a register block with register_init_block32() in its instance_init method; we must therefore destroy it in our instance_finalize method to avoid a leak in the QOM introspection "init-inspect-finalize" lifecycle: Direct leak of 304 byte(s) in 1 object(s) allocated from: #0 0x55f222b5b9d8 in __interceptor_calloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-aarch64+0x294e9d8) (BuildId: 420 43d49e1139e3f3071b1f22fac1e3e7249c9a6) #1 0x7fbb10669c50 in g_malloc0 debian/build/deb/../../../glib/gmem.c:161:13 #2 0x55f222f90c5d in register_init_block hw/core/register.c:248:34 #3 0x55f222f916be in register_init_block32 hw/core/register.c:299:12 #4 0x55f223bbdd15 in efuse_ctrl_init hw/nvram/xlnx-versal-efuse-ctrl.c:718:9 #5 0x55f225b23391 in object_init_with_type qom/object.c:420:9 #6 0x55f225b0a66b in object_initialize_with_type qom/object.c:562:5 #7 0x55f225b0bf0d in object_new_with_type qom/object.c:782:5 #8 0x55f225b0bfe1 in object_new qom/object.c:797:12 #9 0x55f226309e0d in qmp_device_list_properties qom/qom-qmp-cmds.c:144:11 Signed-off-by: Peter Maydell Reviewed-by: Francisco Iglesias Reviewed-by: Francisco Iglesias Reviewed-by: Alistair Francis --- include/hw/nvram/xlnx-versal-efuse.h | 1 + hw/nvram/xlnx-versal-efuse-ctrl.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/hw/nvram/xlnx-versal-efuse.h b/include/hw/nvram/xlnx-versal-efuse.h index 86e2261b9a3..afa4f4f9960 100644 --- a/include/hw/nvram/xlnx-versal-efuse.h +++ b/include/hw/nvram/xlnx-versal-efuse.h @@ -44,6 +44,7 @@ struct XlnxVersalEFuseCtrl { void *extra_pg0_lock_spec; /* Opaque property */ uint32_t extra_pg0_lock_n16; + RegisterInfoArray *reg_array; uint32_t regs[XLNX_VERSAL_EFUSE_CTRL_R_MAX]; RegisterInfo regs_info[XLNX_VERSAL_EFUSE_CTRL_R_MAX]; }; diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c index def6fe3302b..8252a5cabe0 100644 --- a/hw/nvram/xlnx-versal-efuse-ctrl.c +++ b/hw/nvram/xlnx-versal-efuse-ctrl.c @@ -712,9 +712,8 @@ static void efuse_ctrl_init(Object *obj) { XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - RegisterInfoArray *reg_array; - reg_array = + s->reg_array = register_init_block32(DEVICE(obj), efuse_ctrl_regs_info, ARRAY_SIZE(efuse_ctrl_regs_info), s->regs_info, s->regs, @@ -722,7 +721,7 @@ static void efuse_ctrl_init(Object *obj) XLNX_VERSAL_EFUSE_CTRL_ERR_DEBUG, R_MAX * 4); - sysbus_init_mmio(sbd, ®_array->mem); + sysbus_init_mmio(sbd, &s->reg_array->mem); sysbus_init_irq(sbd, &s->irq_efuse_imr); } @@ -730,6 +729,7 @@ static void efuse_ctrl_finalize(Object *obj) { XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj); + register_finalize_block(s->reg_array); g_free(s->extra_pg0_lock_spec); }