From: Andrew Deason Date: Fri, 29 Jun 2018 20:25:48 +0000 (-0500) Subject: afs: Make afs_osi_Free(NULL) a no-op X-Git-Tag: openafs-devel-1_9_0~511 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=7523397333c0f8c6a08312434968d84b8ff56306 afs: Make afs_osi_Free(NULL) a no-op 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 Reviewed-by: Benjamin Kaduk --- diff --git a/src/afs/afs_osi_alloc.c b/src/afs/afs_osi_alloc.c index 1e3648a..4ca4987 100644 --- a/src/afs/afs_osi_alloc.c +++ b/src/afs/afs_osi_alloc.c @@ -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--);