afs: Make afs_osi_Free(NULL) a no-op 36/13236/2
authorAndrew Deason <adeason@sinenomine.net>
Fri, 29 Jun 2018 20:25:48 +0000 (15:25 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 6 Jul 2018 03:37:22 +0000 (23:37 -0400)
In userspace, we assume that free(NULL) does nothing, which makes
certain cleanup code paths simpler. This may or may not be true for
our free() abstractions that can run in the kernel (like afs_osi_Free,
rxi_Free, etc), which is confusing. To make the higher-level free()
abstractions more consistent, change afs_osi_Free to guarantee that
passing a NULL pointer does nothing.

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

src/afs/afs_osi_alloc.c

index 1e3648a..4ca4987 100644 (file)
@@ -63,7 +63,7 @@ void
 afs_osi_Free(void *x, size_t asize)
 {
     AFS_STATCNT(osi_Free);
-    if (x == &memZero)
+    if (x == &memZero || x == NULL)
        return;                 /* check for putting memZero back */
 
     AFS_STATS(afs_stats_cmperf.OutStandingAllocs--);