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.