IB/srpt: Fix memory leak in srpt_add_one
authorMaor Gottlieb <maorg@nvidia.com>
Wed, 28 Oct 2020 06:50:51 +0000 (08:50 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 2 Nov 2020 19:23:55 +0000 (15:23 -0400)
commit372a1786283e50e7cb437ab7fdb1b95597310ad7
tree38b27c68ff0517d2e7882ad309a6310a00fd29ea
parent683a9c7ed81769b6ecb6229afb00b6cda8e4bcfb
IB/srpt: Fix memory leak in srpt_add_one

Failure in srpt_refresh_port() for the second port will leave MAD
registered for the first one, however, the srpt_add_one() will be marked
as "failed" and SRPT will leak resources for that registered but not used
and released first port.

Unregister the MAD agent for all ports in case of failure.

Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
Link: https://lore.kernel.org/r/20201028065051.112430-1-leon@kernel.org
Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/ulp/srpt/ib_srpt.c