lkml.org 
[lkml]   [2022]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 4/4] kunit: make knuit_kfree() not segfault on invalid inputs
On Fri, Jul 22, 2022 at 12:35 AM David Gow <davidgow@google.com> wrote:
> _Maybe_ we should no-op if ptr is NULL. I think it's legal for
> free()/kfree(), and while I don't see much use of it for kunit tests,
> maybe it'll save someone confusion down the road.
>
> But I could live with it either way...

That's a good point.
kfree(NULL) is indeed a no-op.

I can see someone writing a parameterized test w/ some code like
char *buffer = NULL;
if (param->use_buffer) buffer = kunit_kzalloc(test, 10, GFP_KERNEL);
...
kunit_kfree(test, buffer);
and they'd have every reason to think this should just work.

I think I'll tack this on as an extra patch and send a v2 w/ the
commit subject for this one fixed.

\
 
 \ /
  Last update: 2022-07-22 18:50    [W:0.051 / U:0.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site