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 C7B5CA0562; Tue, 4 May 2021 16:16:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 646E940147; Tue, 4 May 2021 16:16:08 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id B74B140141 for ; Tue, 4 May 2021 16:16:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620137765; 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: in-reply-to:in-reply-to:references:references; bh=SSIgf0TPrZoA0WSwv2nX96OAz5ux07KDiwQp2HaZmng=; b=Jn8dT33pozbPcK6QLqw9orH88r1EwsQmZK9oDp9wWGmv1KyoDL2D1kBsspTTEYFgyYwpKW NrD/yKmjPn8AlPilAojoQswTXtE3LZhw/+aIxG+Isv1uKOLYRsVZhwJ6QhobYei+005Hzr No8UpUokq4xWR2zkfIj2srhL3mYsNv4= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-513-Sci6lVYsM5ixjGKVguES0A-1; Tue, 04 May 2021 10:16:03 -0400 X-MC-Unique: Sci6lVYsM5ixjGKVguES0A-1 Received: by mail-vk1-f198.google.com with SMTP id t23-20020ac5c9170000b02901eb5bea4eebso1388453vkl.22 for ; Tue, 04 May 2021 07:16:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SSIgf0TPrZoA0WSwv2nX96OAz5ux07KDiwQp2HaZmng=; b=YmTgd2NaTWhvtP+GimotPoQqe2GogHO9RSKbSM+0N14SsiO45OI8p7JNNdnaS/87vw Lxpm/T0vBnWkMFA2wLqAkjvAwEc936gznWIpblFO9M0OczOAdRlDxT+9EFsWSbXHcYcJ F34EXcfPDEiW9Ia+DWYg5Sgz0XdDEWM0qYkeqTdg3+dLflWczzx7RO79n6LpjU2H7tLV uWZGLQw1oMWFcXyG2RvNWz3QMVIXkcJqIOP3TZRO2eAQLbpPvZ8kBYZFSYL5zSw0EXvv w9WyTDvhHFsrCWPF/dME1YrAfBdWNPvv54ae+JF8L2urrz4AeM+Olm1oL2qANa1egOmL W3qQ== X-Gm-Message-State: AOAM5333E3k+iquIl9Zjh6hdpquehWjLEbYJ6bS2wufoZPMAHuKMkirj EnwPxwA8Dtd7BP4tYOpzEisA1hWT9Qv+zZhWijRI7smJ4j7UyMFhDD1Qy+snuZvUuq6o3wtHFS7 nHM73dv5ZvOvVYLZLPyI= X-Received: by 2002:a9f:368f:: with SMTP id p15mr20317135uap.41.1620137762509; Tue, 04 May 2021 07:16:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXvxDmb4u0NLqNTHJX48insCYYm87g5B/Re32NGY2M4FdMtTaPE/S3QXLkYX91pUzll0JUHsNXPosi1k46Bd0= X-Received: by 2002:a9f:368f:: with SMTP id p15mr20317104uap.41.1620137762283; Tue, 04 May 2021 07:16:02 -0700 (PDT) MIME-Version: 1.0 References: <1619092340-4047-1-git-send-email-humin29@huawei.com> <1619092340-4047-2-git-send-email-humin29@huawei.com> In-Reply-To: <1619092340-4047-2-git-send-email-humin29@huawei.com> From: David Marchand Date: Tue, 4 May 2021 16:15:51 +0200 Message-ID: To: "Min Hu (Connor)" Cc: dev , "Yigit, Ferruh" , Jerin Jacob Kollanukkaran , Kiran Kumar Kokkilagadda Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH 1/2] graph: fix memory leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Apr 22, 2021 at 1:52 PM Min Hu (Connor) wrote: > > From: HongBo Zheng > > Fix function 'stats_mem_populate' return without > free dynamic memory referenced by 'stats'. > > Fixes: af1ae8b6a32c ("graph: implement stats") > Cc: stable@dpdk.org > > Signed-off-by: HongBo Zheng > Signed-off-by: Min Hu (Connor) > --- > lib/librte_graph/graph_stats.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c > index 125e08d..f698bb3 100644 > --- a/lib/librte_graph/graph_stats.c > +++ b/lib/librte_graph/graph_stats.c > @@ -174,7 +174,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, > cluster->stat.hz = rte_get_timer_hz(); > node = graph_node_id_to_ptr(graph, id); > if (node == NULL) > - SET_ERR_JMP(ENOENT, err, "Failed to find node %s in graph %s", > + SET_ERR_JMP(ENOENT, free, "Failed to find node %s in graph %s", > graph_node->node->name, graph->name); > cluster->nodes[cluster->nb_nodes++] = node; > > @@ -183,6 +183,8 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, > *stats_in = stats; > > return 0; > +free: > + free(stats); > err: > return -rte_errno; > } We have a double free with this change. If realloc on stats returns the same location, but node lookup fails, stats_in is left untouched and still points at the original stats location. This location is then freed in the free: label, and later is freed in stats_mem_fini() from caller. -- David Marchand