IB/mlx4: Fix memory leak in add_gid error flow
authorJack Morgenstein <jackm@dev.mellanox.co.il>
Wed, 15 Jan 2020 08:50:50 +0000 (10:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2020 21:33:22 +0000 (16:33 -0500)
commit6ddcb30256b2fa18e15ab36ba33a156cfe436661
tree2bc2ee0a614c5d0da4c3cff7e592a4187d40617f
parent9a7f8a176a73cfc4d966aaea183f2cabf20206e5
IB/mlx4: Fix memory leak in add_gid error flow

commit eaad647e5cc27f7b46a27f3b85b14c4c8a64bffa upstream.

In procedure mlx4_ib_add_gid(), if the driver is unable to update the FW
gid table, there is a memory leak in the driver's copy of the gid table:
the gid entry's context buffer is not freed.

If such an error occurs, free the entry's context buffer, and mark the
entry as available (by setting its context pointer to NULL).

Fixes: e26be1bfef81 ("IB/mlx4: Implement ib_device callbacks")
Link: https://lore.kernel.org/r/20200115085050.73746-1-leon@kernel.org
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/mlx4/main.c