rx: Make rxi_Free(NULL, size) a no-op 14/13514/2
authorAndrew Deason <adeason@sinenomine.net>
Thu, 7 Mar 2019 05:06:16 +0000 (23:06 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 8 Mar 2019 03:32:34 +0000 (22:32 -0500)
Commit 75233973 (afs: Make afs_osi_Free(NULL) a no-op) intended to
make some of our free abstractions behave like the userspace free, so
freeing NULL is a no-op. However, that commit still left rxi_Free such
that rxi_Free(NULL, size) would decrement the relevant allocation
counters.

So to make our free abstractions more consistent, just skip all of
rxi_Free when the given pointer is NULL.

Change-Id: I89047e1846eb3e2932d2a125676fb7ffec8972dc
Reviewed-on: https://gerrit.openafs.org/13514
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/rx/rx.c

index ba63f30..61de8c3 100644 (file)
@@ -2851,6 +2851,9 @@ p = (char *)
 void
 rxi_Free(void *addr, size_t size)
 {
+    if (!addr) {
+        return;
+    }
     if (rx_stats_active) {
        rx_atomic_sub(&rxi_Allocsize, (int) size);
         rx_atomic_dec(&rxi_Alloccnt);