public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber•org>
To: Andrea Claudi <aclaudi@redhat•com>
Cc: netdev@vger•kernel.org, dsahern@gmail•com, markzhang@nvidia•com,
	leonro@nvidia•com
Subject: Re: [PATCH iproute2 1/3] lib/fs: fix memory leak in get_task_name()
Date: Tue, 1 Feb 2022 10:27:12 -0800	[thread overview]
Message-ID: <20220201102712.1390ae4d@hermes.local> (raw)
In-Reply-To: <c7d57346ddc4d9eaaabc0f004911d038c95238af.1643736038.git.aclaudi@redhat.com>

On Tue,  1 Feb 2022 18:39:24 +0100
Andrea Claudi <aclaudi@redhat•com> wrote:

> +	if (fscanf(f, "%ms\n", &comm) != 1) {
> +		free(comm);
> +		return NULL;

This is still leaking the original comm.

Why not change it to use a local variable for the path
(avoid asprintf) and not reuse comm for both pathname
and return value.

  reply	other threads:[~2022-02-01 18:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 17:39 [PATCH iproute2 0/3] some memory leak fixes Andrea Claudi
2022-02-01 17:39 ` [PATCH iproute2 1/3] lib/fs: fix memory leak in get_task_name() Andrea Claudi
2022-02-01 18:27   ` Stephen Hemminger [this message]
2022-02-02 14:38     ` Andrea Claudi
2022-02-02 15:49       ` Stephen Hemminger
2022-02-01 17:39 ` [PATCH iproute2 2/3] rdma: stat: fix memory leak in res_counter_line() Andrea Claudi
2022-02-01 17:39 ` [PATCH iproute2 3/3] rdma: RES_PID and RES_KERN_NAME are alternatives to each other Andrea Claudi

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=20220201102712.1390ae4d@hermes.local \
    --to=stephen@networkplumber$(echo .)org \
    --cc=aclaudi@redhat$(echo .)com \
    --cc=dsahern@gmail$(echo .)com \
    --cc=leonro@nvidia$(echo .)com \
    --cc=markzhang@nvidia$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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