From: Jerin Jacob <jerinjacobk@gmail.com>
To: Marat Khalili <marat.khalili@huawei.com>
Cc: Jerin Jacob <jerinj@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Nithin Dabilpuram <ndabilpuram@marvell.com>,
Zhirun Yan <yanzhirun_163@163.com>,
dev@dpdk.org
Subject: Re: [PATCH 1/2] lib/graph: avoid memset(NULL, 0, 0)
Date: Tue, 17 Jun 2025 18:11:41 +0530 [thread overview]
Message-ID: <CALBAE1NiJjW2oRA++TXGiVqFSiR5KHe3dVy8AEDcg3fT4Z4mfQ@mail.gmail.com> (raw)
In-Reply-To: <20250617105209.50526-1-marat.khalili@huawei.com>
On Tue, Jun 17, 2025 at 4:22 PM Marat Khalili <marat.khalili@huawei.com> wrote:
>
> 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
>
> To fix the issue add a check that stat->xstat_count is not NULL before
> the call.
>
> Signed-off-by: Marat Khalili <marat.khalili@huawei.com>
Change subject as lib/graph: fix memset with NULL. Also add Fixes:
With that
Acked-by: Jerin Jacob <jerinj@marvell.com>
> ---
> lib/graph/graph_stats.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
> index eac73cbf71..57cd72e7cc 100644
> --- a/lib/graph/graph_stats.c
> +++ b/lib/graph/graph_stats.c
> @@ -470,7 +470,9 @@ 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_count != NULL)
> + memset(stat->xstat_count, 0,
> + sizeof(uint64_t) * stat->xstat_cntrs);
> for (count = 0; count < cluster->nb_nodes; count++) {
> node = cluster->nodes[count];
>
> --
> 2.43.0
>
prev parent reply other threads:[~2025-06-17 12:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 10:52 Marat Khalili
2025-06-17 10:52 ` [PATCH 2/2] lib/graph: rte_malloc for cache-aligned structs Marat Khalili
2025-06-17 12:46 ` Jerin Jacob
2025-06-17 13:27 ` Stephen Hemminger
2025-06-17 14:16 ` Jerin Jacob
2025-06-17 12:41 ` Jerin Jacob [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALBAE1NiJjW2oRA++TXGiVqFSiR5KHe3dVy8AEDcg3fT4Z4mfQ@mail.gmail.com \
--to=jerinjacobk@gmail.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=marat.khalili@huawei.com \
--cc=ndabilpuram@marvell.com \
--cc=yanzhirun_163@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).