]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: Make afs_osi_Free(NULL) a no-op
authorAndrew Deason <adeason@sinenomine.net>
Fri, 29 Jun 2018 20:25:48 +0000 (15:25 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 27 Jul 2018 13:26:24 +0000 (09:26 -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.

Reviewed-on: https://gerrit.openafs.org/13236
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 7523397333c0f8c6a08312434968d84b8ff56306)

Change-Id: Ifda1bd8c99f128fe01d38fd64dc19afee4c5158f
Reviewed-on: https://gerrit.openafs.org/13250
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
src/afs/afs_osi_alloc.c

index 1e3648af8ea7ad9ee5088e4003cec0a19bcc7582..4ca4987b75ea21016a737a92218693a846f1271f 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--);