archive mirror
 help / color / mirror / Atom feed
From: David Miller <>
Subject: Re: [Linux-kernel-mentees] [PATCH] net: team: fix memory leak in __team_options_register
Date: Sun, 04 Oct 2020 14:48:23 -0700 (PDT)	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

From: Anant Thazhemadam <>
Date: Mon,  5 Oct 2020 02:25:36 +0530

> The variable "i" isn't initialized back correctly after the first loop
> under the label inst_rollback gets executed.
> The value of "i" is assigned to be option_count - 1, and the ensuing 
> loop (under alloc_rollback) begins by initializing i--. 
> Thus, the value of i when the loop begins execution will now become 
> i = option_count - 2.
> Thus, when kfree(dst_opts[i]) is called in the second loop in this 
> order, (i.e., inst_rollback followed by alloc_rollback), 
> dst_optsp[option_count - 2] is the first element freed, and 
> dst_opts[option_count - 1] does not get freed, and thus, a memory 
> leak is caused.
> This memory leak can be fixed, by assigning i = option_count (instead of
> option_count - 1).
> Fixes: 80f7c6683fe0 ("team: add support for per-port options")
> Reported-by:
> Tested-by:
> Signed-off-by: Anant Thazhemadam <>

Applied and queued up for -stable, thank you.
Linux-kernel-mentees mailing list

      reply	other threads:[~2020-10-04 21:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-04 20:55 [Linux-kernel-mentees] [PATCH] net: team: fix memory leak in __team_options_register Anant Thazhemadam
2020-10-04 21:48 ` David Miller [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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \

* 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).