From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8FEB946B27 for ; Tue, 8 Jul 2025 14:31:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88C6540B95; Tue, 8 Jul 2025 14:31:25 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 269FB40B98 for ; Tue, 8 Jul 2025 14:31:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751977883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=69Cl5rH1nJhTguHVgodvWy1LNsMZCt5T/T/J6ytWcGo=; b=DSe5t7ENLPPHgeZ9wvNtCPgK0UCzxdOQfk/FKTTe44DJWStsmKxywJH1jVfGXxRZyq9BEo kiOnSztAwYcr6x5I5jjkh644FhsfAVafY6kWuaX50SRBJkDOLnUVLGezu8bcSOscFB04s1 z6HAKjoCzxg8N4i+PbDYgY6WyaIoLYc= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-497-XZr2EBHXPcSQFLFCC-bdBw-1; Tue, 08 Jul 2025 08:31:22 -0400 X-MC-Unique: XZr2EBHXPcSQFLFCC-bdBw-1 X-Mimecast-MFC-AGG-ID: XZr2EBHXPcSQFLFCC-bdBw_1751977881 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D2B0419560A2; Tue, 8 Jul 2025 12:31:20 +0000 (UTC) Received: from dmarchan.lan (unknown [10.44.33.95]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 12F8819560AD; Tue, 8 Jul 2025 12:31:16 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Marat Khalili , stable@dpdk.org, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan , Pavan Nikhilesh , Robin Jarry Subject: [PATCH v3 13/18] graph: fix stats query with no node xstats Date: Tue, 8 Jul 2025 14:28:17 +0200 Message-ID: <20250708122823.3406288-14-david.marchand@redhat.com> In-Reply-To: <20250708122823.3406288-1-david.marchand@redhat.com> References: <20250619071037.37325-1-david.marchand@redhat.com> <20250708122823.3406288-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oJ5lvQ59iiXRO2DRvXJK4Is3s4ZxL66xzDIbiWOeItE_1751977881 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Marat Khalili This was flagged by undefined behaviour sanitizer: memset should not be called with NULL first argument. (memset requires first argument to be pointer to a memory object, so passing NULL may result in an undefined behaviour including among other things optimizer potentially removing code paths depending on stat->xstat_count being NULL.) Sanitizer message: lib/graph/graph_stats.c:473:2: runtime error: null pointer passed as argument 1, which is declared to never be null Add a check that stat->xstat_cntrs is not zero before the call, since stat->xstat_count can only be NULL when stat->xstat_cntrs is zero. Fixes: 070db97e017b ("graph: support node xstats") Cc: stable@dpdk.org Signed-off-by: Marat Khalili --- lib/graph/graph_stats.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c index eac73cbf71..583ad8dbd5 100644 --- a/lib/graph/graph_stats.c +++ b/lib/graph/graph_stats.c @@ -470,7 +470,8 @@ cluster_node_arregate_stats(struct cluster_node *cluster, bool dispatch) uint64_t *xstat; uint8_t i; - memset(stat->xstat_count, 0, sizeof(uint64_t) * stat->xstat_cntrs); + if (stat->xstat_cntrs != 0) + memset(stat->xstat_count, 0, sizeof(uint64_t) * stat->xstat_cntrs); for (count = 0; count < cluster->nb_nodes; count++) { node = cluster->nodes[count]; -- 2.50.0