]> git.baikalelectronics.ru Git - kernel.git/commit
vdpa/mlx5: fix memory allocation failure checks
authorColin Ian King <colin.king@canonical.com>
Thu, 6 Aug 2020 16:08:28 +0000 (17:08 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 10 Aug 2020 13:01:21 +0000 (09:01 -0400)
commit51217e02866517380891faf2fe107027664267ed
tree81b4b4987d882b8be316a57b99b313833b799fb4
parent0645eae2480a506c42f9667171713f9168e2ba54
vdpa/mlx5: fix memory allocation failure checks

The memory allocation failure checking for in and out is currently
checking if the pointers are valid rather than the contents of what
they point to. Hence the null check on failed memory allocations is
incorrect.  Fix this by adding the missing indirection in the check.
Also for the default case, just set the *in and *out to null as
these don't have any thing allocated to kfree. Finally remove the
redundant *in and *out check as these have been already done on each
allocation in the case statement.

Addresses-Coverity: ("Null pointer dereference")
Fixes: 89495935b0eb ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200806160828.90463-1-colin.king@canonical.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Eli Cohen <eli@mellanox.com>
drivers/vdpa/mlx5/net/mlx5_vnet.c