Re: lib/argv_split.c : should argv be kfree'ed ?

From: Toralf FÃrster
Date: Sun Jun 29 2014 - 10:40:34 EST


On 06/29/2014 12:04 AM, Mateusz Guzik wrote:
> On Sat, Jun 28, 2014 at 11:52:37PM +0200, Toralf FÃrster wrote:
>> /me wonders if this patch is needed here :
>>
>>
>> diff --git a/lib/argv_split.c b/lib/argv_split.c
>> index e927ed0..7de4cb4 100644
>> --- a/lib/argv_split.c
>> +++ b/lib/argv_split.c
>> @@ -85,6 +85,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp)
>> *argv++ = argv_str;
>> }
>> }
>> + kfree (argv);
>> *argv = NULL;
>>
>> if (argcp)
>>
>
> No, see argv_free.
>
Ah, understood, it is in the responsibility of the caller to avoid the memleak.
BTW may I ask you about your opinion about this warning of cppcheck in lib/flex_array.c:

for (part_nr = start_part; part_nr <= end_part; part_nr++) {<--- Memory leak: part
part = __fa_get_part(fa, part_nr, flags);
if (!part)
return -ENOMEM;
}
return 0;

--
Toralf

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/