From 98e1ea0f178bdb8d26037edda9aae7bc2339bac4 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 7 Oct 2010 03:20:59 +0000 Subject: Possible race condition between cleanup and dereferencing Signed-off-by: shishir gowda Signed-off-by: Vijay Bellur BUG: 1760 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1760 --- xlators/cluster/stripe/src/stripe.c | 1 + xlators/debug/io-stats/src/io-stats.c | 4 ++++ xlators/encryption/rot-13/src/rot-13.c | 3 +++ xlators/features/locks/src/posix.c | 3 +++ xlators/performance/stat-prefetch/src/stat-prefetch.c | 3 ++- xlators/performance/write-behind/src/write-behind.c | 3 +++ xlators/protocol/legacy/transport/socket/src/socket.c | 3 +++ xlators/storage/posix/src/posix.c | 3 +++ 8 files changed, 22 insertions(+), 1 deletion(-) (limited to 'xlators') diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index a8ac55aa4..d37f38ca6 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -3941,6 +3941,7 @@ fini (xlator_t *this) priv = this->private; if (priv) { + this->private = NULL; if (priv->xl_array) GF_FREE (priv->xl_array); diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index e87334364..2061d9bc9 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -1695,6 +1695,10 @@ fini (xlator_t *this) conf = this->private; + if (!conf) + return; + this->private = NULL; + GF_FREE(conf); gf_log (this->name, GF_LOG_NORMAL, diff --git a/xlators/encryption/rot-13/src/rot-13.c b/xlators/encryption/rot-13/src/rot-13.c index 98bfd1b5a..39549d8be 100644 --- a/xlators/encryption/rot-13/src/rot-13.c +++ b/xlators/encryption/rot-13/src/rot-13.c @@ -181,6 +181,9 @@ fini (xlator_t *this) { rot_13_private_t *priv = this->private; + if (!priv) + return; + this->private = NULL; GF_FREE (priv); return; diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 36c399c11..29b3bb079 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -1885,6 +1885,9 @@ fini (xlator_t *this) posix_locks_private_t *priv = NULL; priv = this->private; + if (!priv) + return 0; + this->private = NULL; GF_FREE (priv); return 0; diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index 972afe313..0a984908f 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -777,7 +777,7 @@ sp_cache_add_entries (sp_cache_t *cache, gf_dirent_t *entries) sp_private_t *priv = NULL; this = cache->this; - if (this) + if (this && this->private) priv = this->private; LOCK (&cache->lock); @@ -3676,6 +3676,7 @@ fini (xlator_t *this) mem_pool_destroy (priv->mem_pool); LOCK_DESTROY (&priv->lock); GF_FREE (priv); + this->private = NULL; } } out: diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index 8a4be0f7f..42fc0bb7e 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -3009,6 +3009,9 @@ fini (xlator_t *this) { wb_conf_t *conf = this->private; + if (!conf) + return; + this->private = NULL; GF_FREE (conf); return; } diff --git a/xlators/protocol/legacy/transport/socket/src/socket.c b/xlators/protocol/legacy/transport/socket/src/socket.c index 7b68e3a3e..854529ca2 100644 --- a/xlators/protocol/legacy/transport/socket/src/socket.c +++ b/xlators/protocol/legacy/transport/socket/src/socket.c @@ -1547,6 +1547,9 @@ fini (transport_t *this) { socket_private_t *priv = this->private; + if (!priv) + return; + this->private = NULL; gf_log (this->xl->name, GF_LOG_TRACE, "transport %p destroyed", this); diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index ef5dae218..51e4230ae 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -4438,6 +4438,9 @@ void fini (xlator_t *this) { struct posix_private *priv = this->private; + if (!priv) + return; + this->private = NULL; sys_lremovexattr (priv->base_path, "trusted.glusterfs.test"); GF_FREE (priv); return; -- cgit