[lustre-devel] [PATCH 2/7] lustre/libcfs: fix freeing after kmalloc failure.

James Simmons jsimmons at infradead.org
Wed Aug 1 20:46:00 PDT 2018


> The new_bkts array is *not* zeroed (any more) so when
> freeing recently allocated buckets on failure, we
> must no free beyond the last bucket successfully
> allocated.

Reviewed-by: James Simmons <jsimmons at infradead.org>
 
> Fixes: 12e46c461cb9 ("staging: lustre: change some LIBCFS_ALLOC calls to k?alloc(GFP_KERNEL)")
> Signed-off-by: NeilBrown <neilb at suse.com>
> ---
>  drivers/staging/lustre/lnet/libcfs/hash.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c
> index 48be66f0d654..f452c4540ca1 100644
> --- a/drivers/staging/lustre/lnet/libcfs/hash.c
> +++ b/drivers/staging/lustre/lnet/libcfs/hash.c
> @@ -904,7 +904,7 @@ cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts,
>  		new_bkts[i] = kzalloc(cfs_hash_bkt_size(hs), GFP_KERNEL);
>  		if (!new_bkts[i]) {
>  			cfs_hash_buckets_free(new_bkts, cfs_hash_bkt_size(hs),
> -					      old_size, new_size);
> +					      old_size, i);
>  			return NULL;
>  		}
>  
> 
> 
> 


More information about the lustre-devel mailing list