From: Gal Pressman <galpress@amazon.com>
To: Ivan Vecera <cera@cera.cz>, <linville@tuxdriver.com>
Cc: <netdev@vger.kernel.org>, Gal Pressman <galp@mellanox.com>
Subject: Re: [PATCH ethtool 5/6] ethtool: correctly free hkey when get_stringset() fails
Date: Fri, 8 Jun 2018 12:46:14 +0300 [thread overview]
Message-ID: <febd4aab-8a09-e4c5-37db-2d7ef6cbe864@amazon.com> (raw)
In-Reply-To: <20180608092010.13041-5-cera@cera.cz>
On 08-Jun-18 12:20, Ivan Vecera wrote:
> Memory allocated for 'hkey' is not freed when
> get_stringset(..., ETH_SS_RSS_HASH_FUNCS...) fails.
>
> Fixes: b888f35 ("ethtool: Support for configurable RSS hash function")
Thanks for fixing this!
Please use the first 12 characters of the sha1 in the Fixes line.
> Cc: Gal Pressman <galp@mellanox.com>
> Signed-off-by: Ivan Vecera <cera@cera.cz>
> ---
> ethtool.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/ethtool.c b/ethtool.c
> index 2b90984..fb93ae8 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -3910,7 +3910,7 @@ static int do_srxfhindir(struct cmd_context *ctx, int rxfhindir_default,
> static int do_srxfh(struct cmd_context *ctx)
> {
> struct ethtool_rxfh rss_head = {0};
> - struct ethtool_rxfh *rss;
> + struct ethtool_rxfh *rss = NULL;
> struct ethtool_rxnfc ring_count;
> int rxfhindir_equal = 0, rxfhindir_default = 0;
> struct ethtool_gstrings *hfuncs = NULL;
> @@ -4064,7 +4064,8 @@ static int do_srxfh(struct cmd_context *ctx)
> hfuncs = get_stringset(ctx, ETH_SS_RSS_HASH_FUNCS, 0, 1);
> if (!hfuncs) {
> perror("Cannot get hash functions names");
> - return 1;
> + err = 1;
> + goto free;
> }
>
> for (i = 0; i < hfuncs->len && !req_hfunc ; i++) {
> @@ -4078,8 +4079,8 @@ static int do_srxfh(struct cmd_context *ctx)
> if (!req_hfunc) {
> fprintf(stderr,
> "Unknown hash function: %s\n", req_hfunc_name);
> - free(hfuncs);
> - return 1;
> + err = 1;
> + goto free;
> }
> }
>
> @@ -4120,9 +4121,7 @@ static int do_srxfh(struct cmd_context *ctx)
> }
>
> free:
> - if (hkey)
> - free(hkey);
> -
> + free(hkey);
> free(rss);
> free(hfuncs);
> return err;
>
next prev parent reply other threads:[~2018-06-08 9:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-08 9:20 [PATCH ethtool 1/6] ethtool: fix uninitialized return value Ivan Vecera
2018-06-08 9:20 ` [PATCH ethtool 2/6] ethtool: fix RING_VF assignment Ivan Vecera
2018-06-08 15:20 ` Keller, Jacob E
2018-06-08 9:20 ` [PATCH ethtool 3/6] ethtool: remove unused global variable Ivan Vecera
2018-06-08 9:20 ` [PATCH ethtool 4/6] ethtool: several fixes in do_gregs() Ivan Vecera
2018-06-08 9:20 ` [PATCH ethtool 5/6] ethtool: correctly free hkey when get_stringset() fails Ivan Vecera
2018-06-08 9:46 ` Gal Pressman [this message]
2018-06-08 9:20 ` [PATCH ethtool 6/6] ethtool: remove unreachable code Ivan Vecera
2018-06-13 18:31 ` [PATCH ethtool 1/6] ethtool: fix uninitialized return value John W. Linville
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=febd4aab-8a09-e4c5-37db-2d7ef6cbe864@amazon.com \
--to=galpress@amazon.com \
--cc=cera@cera.cz \
--cc=galp@mellanox.com \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
/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).