[sheepdog] [PATCH] sheep/object_cache: fix potential crash in object_cache_remove

Liu Yuan namei.unix at gmail.com
Tue Apr 22 08:04:34 CEST 2014


On Mon, Apr 21, 2014 at 06:11:01PM +0800, Ruoyu wrote:
> 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>
> ---
>  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
> 
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog

Applied thanks

Yuan



More information about the sheepdog mailing list