Re: [PATCH net v2] ice: Add check for kzalloc

From: Jiri Pirko
Date: Thu Dec 08 2022 - 06:18:11 EST


Thu, Dec 08, 2022 at 11:06:03AM CET, jiasheng@xxxxxxxxxxx wrote:
>On Thu, Dec 08, 2022 at 05:25:02PM +0800, Leon Romanovsky wrote:
>>> +err_out:
>>> + for (j = 0; j < i; j++) {
>>
>> You don't need an extra variable, "while(i--)" will do the trick.
>
>No, the right range is [0, i - 1], but the "while(i--)" is [1, i].

Are you sure??


>If using "while(i--)", the code should be "tty_port_destroy(pf->gnss_tty_port[i - 1]);".
>It will be more complex.
>Therefore, it is worthwhile to use an extra varaible.
>
>Thanks,
>Jiang
>