From: Doug Ledford <dledford@redhat.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Yishai Hadas <yishaih@mellanox.com>
Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] net/mlx4: fix some error handling in mlx4_multi_func_init()
Date: Thu, 11 Feb 2016 11:02:10 -0500 [thread overview]
Message-ID: <56BCB082.4030701@redhat.com> (raw)
In-Reply-To: <1455048677-19882-4-git-send-email-linux@rasmusvillemoes.dk>
[-- Attachment #1: Type: text/plain, Size: 2106 bytes --]
On 02/09/2016 03:11 PM, Rasmus Villemoes wrote:
> The while loop after err_slaves should use post-decrement; otherwise
> we'll fail to do the kfrees for i==0, and will run into out-of-bounds
> accesses if the setup above failed already at i==0.
>
> The predecrement in the --port is ok, since ->vlan_filter is
> (bizarrely) 1-indexed. But I'm changing 'if' to 'while' since it's a
> bit ugly to rely on MLX4_MAX_PORTS being 2.
>
> [I'm not sure why one even bothers populating the ->vlan_filter array:
> mlx4.h isn't #included by anything outside
> drivers/net/ethernet/mellanox/mlx4/, and "git grep -C2 -w vlan_filter
> drivers/net/ethernet/mellanox/mlx4/" seems to suggest that the
> vlan_filter elements aren't used at all.]
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/net/ethernet/mellanox/mlx4/cmd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> index d48d5793407d..bfe8234abbba 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> @@ -2369,7 +2369,7 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
> kzalloc(sizeof(struct mlx4_vlan_fltr),
> GFP_KERNEL);
> if (!s_state->vlan_filter[port]) {
> - if (--port)
> + while (--port)
> kfree(s_state->vlan_filter[port]);
> goto err_slaves;
> }
> @@ -2429,7 +2429,7 @@ err_thread:
> flush_workqueue(priv->mfunc.master.comm_wq);
> destroy_workqueue(priv->mfunc.master.comm_wq);
> err_slaves:
> - while (--i) {
> + while (i--) {
> for (port = 1; port <= MLX4_MAX_PORTS; port++)
> kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]);
> }
>
I'm modifying your patch slightly (dropping the first hunk, it isn't
really necessary as Yishai pointed out in review) and adjusting the
description to compensate. I'll apply the result to my next for-rc series.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: 0E572FDD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]
next prev parent reply other threads:[~2016-02-11 16:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-09 20:11 [PATCH 0/5] pre-decrement in error paths considered harmful Rasmus Villemoes
2016-02-09 20:11 ` [PATCH 1/5] drm/gma500: fix error path in gma_intel_setup_gmbus() Rasmus Villemoes
2016-02-10 6:41 ` Andy Shevchenko
2016-02-10 7:26 ` Daniel Vetter
2016-02-09 20:11 ` [PATCH 2/5] drm/i915: fix error path in intel_setup_gmbus() Rasmus Villemoes
2016-02-09 20:27 ` Jani Nikula
2016-02-10 8:56 ` Jani Nikula
2016-02-09 20:11 ` [PATCH 3/5] net/mlx4: fix some error handling in mlx4_multi_func_init() Rasmus Villemoes
2016-02-10 9:40 ` Yishai Hadas
2016-02-10 18:15 ` Rasmus Villemoes
2016-02-11 9:29 ` Jack Morgenstein
2016-02-11 10:20 ` Jack Morgenstein
2016-02-11 16:02 ` Doug Ledford [this message]
2016-02-09 20:11 ` [PATCH 4/5] net: sxgbe: fix error paths in sxgbe_platform_probe() Rasmus Villemoes
2016-03-08 20:44 ` Rasmus Villemoes
2016-03-22 19:47 ` Rasmus Villemoes
2016-03-26 21:24 ` [PATCH] " Rasmus Villemoes
2016-03-27 8:22 ` Francois Romieu
2016-03-27 21:40 ` Rasmus Villemoes
2016-03-28 2:39 ` David Miller
2016-03-28 2:40 ` David Miller
2016-02-09 20:11 ` [PATCH 5/5] mm/backing-dev.c: fix error path in wb_init() Rasmus Villemoes
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=56BCB082.4030701@redhat.com \
--to=dledford@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=netdev@vger.kernel.org \
--cc=yishaih@mellanox.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).