From: Alex Dewar Date: Thu, 6 Aug 2020 18:56:15 +0000 (+0100) Subject: vdpa/mlx5: Fix uninitialised variable in core/mr.c X-Git-Tag: v5.15~3122^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05acc4beb24c7e5ed3ae20a3d3ab2b29b40cb385;p=platform%2Fkernel%2Flinux-starfive.git vdpa/mlx5: Fix uninitialised variable in core/mr.c If the kernel is unable to allocate memory for the variable dmr then err will be returned without being set. Set err to -ENOMEM in this case. Fixes: 94abbccdf291 ("vdpa/mlx5: Add shared memory registration code") Addresses-Coverity: ("Uninitialized variables") Signed-off-by: Alex Dewar Link: https://lore.kernel.org/r/20200806185625.67344-1-alex.dewar@gmx.co.uk Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Acked-by: Eli Cohen --- diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c index f5dec02..ef1c550 100644 --- a/drivers/vdpa/mlx5/core/mr.c +++ b/drivers/vdpa/mlx5/core/mr.c @@ -319,8 +319,10 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev, u64 start, u64 size, u8 while (size) { sz = (u32)min_t(u64, MAX_KLM_SIZE, size); dmr = kzalloc(sizeof(*dmr), GFP_KERNEL); - if (!dmr) + if (!dmr) { + err = -ENOMEM; goto err_alloc; + } dmr->start = st; dmr->end = st + sz;