Commit 05acc4be authored by Alex Dewar's avatar Alex Dewar Committed by Michael S. Tsirkin

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: 94abbccd ("vdpa/mlx5: Add shared memory registration code")
Addresses-Coverity: ("Uninitialized variables")
Signed-off-by: default avatarAlex Dewar <alex.dewar@gmx.co.uk>
Link: https://lore.kernel.org/r/20200806185625.67344-1-alex.dewar@gmx.co.ukSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Acked-by: default avatarEli Cohen <eli@mellanox.com>
parent 1e3e7926
...@@ -319,8 +319,10 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev, u64 start, u64 size, u8 ...@@ -319,8 +319,10 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev, u64 start, u64 size, u8
while (size) { while (size) {
sz = (u32)min_t(u64, MAX_KLM_SIZE, size); sz = (u32)min_t(u64, MAX_KLM_SIZE, size);
dmr = kzalloc(sizeof(*dmr), GFP_KERNEL); dmr = kzalloc(sizeof(*dmr), GFP_KERNEL);
if (!dmr) if (!dmr) {
err = -ENOMEM;
goto err_alloc; goto err_alloc;
}
dmr->start = st; dmr->start = st;
dmr->end = st + sz; dmr->end = st + sz;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment