From 4b42b490fc1c2223a465981a59914b37773ad84a Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 29 Jun 2018 15:25:48 -0500 Subject: [PATCH] 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. Reviewed-on: https://gerrit.openafs.org/13236 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit 7523397333c0f8c6a08312434968d84b8ff56306) Change-Id: Ifda1bd8c99f128fe01d38fd64dc19afee4c5158f Reviewed-on: https://gerrit.openafs.org/13250 Tested-by: BuildBot Reviewed-by: Mark Vitale Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk --- src/afs/afs_osi_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afs/afs_osi_alloc.c b/src/afs/afs_osi_alloc.c index 1e3648af8..4ca4987b7 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--); -- 2.39.5