[sheepdog] [PATCH stable-0.8 2/4] sheep/object_cache: fix potential crash in object_cache_remove
Hitoshi Mitake
mitake.hitoshi at gmail.com
Tue Apr 22 16:57:23 CEST 2014
From: Ruoyu <liangry at ucweb.com>
If object is not found, entry reference to NULL, the below statement
will cause a crash.
struct object_cache *oc = entry->oc;
Signed-off-by: Ruoyu <liangry at ucweb.com>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
sheep/object_cache.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index d51d459..728eacc 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -1293,12 +1293,14 @@ int object_cache_remove(uint64_t oid)
{
/* Inc the entry refcount to exclude the reclaimer */
struct object_cache_entry *entry = oid_to_entry(oid);
- struct object_cache *oc = entry->oc;
+ struct object_cache *oc;
int ret;
if (!entry)
return SD_RES_NO_OBJ;
+ oc = entry->oc;
+
sd_debug("%" PRIx64, oid);
while (refcount_read(&entry->refcnt) > 1)
usleep(100000); /* Object might be in push */
--
1.8.3.2
More information about the sheepdog
mailing list