RDMA/rxe: Fix coding error in rxe_rcv_mcast_pkt
authorBob Pearson <rpearsonhpe@gmail.com>
Thu, 28 Jan 2021 17:47:53 +0000 (11:47 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 10:38:04 +0000 (11:38 +0100)
commit54bdcd7b8f0a6b60355a26ac889fa09f1940a79d
tree4f00681c2d00284fe6b92d4ede7c27be5a241cb3
parentd464194f6e47f1ef005a2e0d7b51ebb9de8e3e95
RDMA/rxe: Fix coding error in rxe_rcv_mcast_pkt

[ Upstream commit 8fc1b7027fc162738d5a85c82410e501a371a404 ]

rxe_rcv_mcast_pkt() in rxe_recv.c can leak SKBs in error path code. The
loop over the QPs attached to a multicast group creates new cloned SKBs
for all but the last QP in the list and passes the SKB and its clones to
rxe_rcv_pkt() for further processing. Any QPs that do not pass some checks
are skipped.  If the last QP in the list fails the tests the SKB is
leaked.  This patch checks if the SKB for the last QP was used and if not
frees it. Also removes a redundant loop invariant assignment.

Fixes: 8700e3e7c485 ("Soft RoCE driver")
Fixes: 71abf20b28ff ("RDMA/rxe: Handle skb_clone() failure in rxe_recv.c")
Link: https://lore.kernel.org/r/20210128174752.16128-1-rpearson@hpe.com
Signed-off-by: Bob Pearson <rpearson@hpe.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/sw/rxe/rxe_recv.c