Re: [PATCH 4/4] kunit: make knuit_kfree() not segfault on invalid inputs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 22, 2022 at 12:35 AM David Gow <davidgow@xxxxxxxxxx> 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.



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux