RDMA/core: Fix use after free and refcnt leak on ndev in_device in iwarp_query_port
authorMichal Kalderon <michal.kalderon@marvell.com>
Wed, 25 Sep 2019 12:33:32 +0000 (15:33 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 1 Oct 2019 14:31:27 +0000 (11:31 -0300)
commit390d3fdcae2da52755b31aa44fcf19ecb5a2488b
tree55c6f62c8be34f0f884993d3249513cf3ac8dacc
parentdf791c54d627bae53c9be3be40a69594c55de487
RDMA/core: Fix use after free and refcnt leak on ndev in_device in iwarp_query_port

If an iWARP driver is probed and removed while there are no ips set for
the device, it will lead to a reference count leak on the inet device of
the netdevice.

In addition, the netdevice was accessed after already calling netdev_put,
which could lead to using the netdev after already freed.

Fixes: 4929116bdf72 ("RDMA/core: Add common iWARP query port")
Link: https://lore.kernel.org/r/20190925123332.10746-1-michal.kalderon@marvell.com
Signed-off-by: Ariel Elior <ariel.elior@marvell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>
Reviewed-by: Kamal Heib <kamalheib1@gmail.com>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/device.c