[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231114193350.475050ae@hermes.local>
Date: Tue, 14 Nov 2023 19:33:50 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: heminhong <heminhong@...inos.cn>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH v2] iproute2: prevent memory leak
On Wed, 15 Nov 2023 10:37:03 +0800
heminhong <heminhong@...inos.cn> wrote:
> When the return value of rtnl_talk() is less than 0, 'answer' does not
> need to release. When the return value of rtnl_talk() is greater than
> or equal to 0, 'answer' will be allocated, if subsequent processing fails,
> the memory should be free, otherwise it will cause memory leak.
>
> Signed-off-by: heminhong <heminhong@...inos.cn>
No null check needed before free().
free()
The free() function frees the memory space pointed to by ptr, which
must have been returned by a previous call to malloc() or related func‐
tions. Otherwise, or if ptr has already been freed, undefined behavior
occurs. If ptr is NULL, no operation is performed.
Powered by blists - more mailing lists