Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1331418

Re: [PATCH 3/5] net/mlx4: fix some error handling in mlx4_multi_func_init()

From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject Re: [PATCH 3/5] net/mlx4: fix some error handling in mlx4_multi_func_init()
Date 2016-02-10 19:20 +0100
Message-ID <r0HwS-5Rl-13@gated-at.bofh.it> (permalink)
References <r0mVr-wW-3@gated-at.bofh.it> <r0mVt-wW-39@gated-at.bofh.it> <r0zzk-sv-7@gated-at.bofh.it>
Organization D03

Show all headers | View raw


On Wed, Feb 10 2016, Yishai Hadas <yishaih@dev.mellanox.co.il> wrote:

>> @@ -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--) {
>
> This fix is wrong as it hits the case that i arrived the last value
> then below code will access to a non valid entry in the array.
>
> The expected fix should be:
> while (--i >= 0)
>

Huh? They're completely equivalent (given that i is necessarily
non-negative before we evaluate the loop condition). I don't really care
either way, but git grep says that 'while (i--)' is 5 times more common
than 'while (--i >= 0)'.

Rasmus

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] pre-decrement in error paths considered harmful Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-09 21:20 +0100
  [PATCH 5/5] mm/backing-dev.c: fix error path in wb_init() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-09 21:20 +0100
  [PATCH 4/5] net: sxgbe: fix error paths in sxgbe_platform_probe() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-09 21:20 +0100
  [PATCH 1/5] drm/gma500: fix error path in gma_intel_setup_gmbus() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-09 21:20 +0100
    Re: [PATCH 1/5] drm/gma500: fix error path in gma_intel_setup_gmbus() Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-02-10 07:50 +0100
      Re: [PATCH 1/5] drm/gma500: fix error path in gma_intel_setup_gmbus() Daniel Vetter <daniel@ffwll.ch> - 2016-02-10 08:30 +0100
  [PATCH 3/5] net/mlx4: fix some error handling in mlx4_multi_func_init() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-09 21:20 +0100
    Re: [PATCH 3/5] net/mlx4: fix some error handling in  mlx4_multi_func_init() Yishai Hadas <yishaih@dev.mellanox.co.il> - 2016-02-10 10:50 +0100
      Re: [PATCH 3/5] net/mlx4: fix some error handling in mlx4_multi_func_init() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-10 19:20 +0100
        Re: [PATCH 3/5] net/mlx4: fix some error handling in  mlx4_multi_func_init() Jack Morgenstein <jackm@dev.mellanox.co.il> - 2016-02-11 10:30 +0100
          Re: [PATCH 3/5] net/mlx4: fix some error handling in  mlx4_multi_func_init() Jack Morgenstein <jackm@dev.mellanox.co.il> - 2016-02-11 11:30 +0100
    Re: [PATCH 3/5] net/mlx4: fix some error handling in  mlx4_multi_func_init() Doug Ledford <dledford@redhat.com> - 2016-02-11 17:10 +0100

csiph-web