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

From: Rasmus Villemoes
Date: Wed Feb 10 2016 - 13:15:30 EST


On Wed, Feb 10 2016, Yishai Hadas <yishaih@xxxxxxxxxxxxxxxxxx> 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