Skip to contentSkip to conversation

RDMA/cxgb4: Fix neigh reference leak in rx_pkt()

PATCH Applied Wentao Liang 2 participants 2 messages Sep 16 – Sep 23

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 3/5 RDMA/cxgb4: Fix neigh reference leak in rx_pkt()

If ip_dev_find() fails on the loopback path the code jumps to free_dst without releasing the neighbour reference taken by dst_neigh_lookup_skb(), leaking one neigh reference.

Release the neighbour before jumping to free_dst.

Fixes ef42520240aa ("RDMA/cxgb4: add null-ptr-check after ip_dev_find()")
---
 drivers/infiniband/hw/cxgb4/cm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/hw/cxgb4/cm.c +1 -0
index b3b45c49077d..f57a31cf4fc7 100644
@@ -4156,6 +4156,7 @@ static int rx_pkt(struct c4iw_dev *dev, struct sk_buff *skb)
 		pdev = ip_dev_find(&init_net, iph->daddr);
 		if (!pdev) {
 			pr_err("%s - failed to find device!\n", __func__);
+			neigh_release(neigh);
 			goto free_dst;
 		}
 		e = cxgb4_l2t_get(dev->rdev.lldi.l2t, neigh,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · Wentao Liang

If ip_dev_find() fails on the loopback path the code jumps to free_dst without releasing the neighbour reference taken by dst_neigh_lookup_skb(), leaking one neigh reference.

Release the neighbour before jumping to free_dst.

[...]

Applied, thanks!

[3/5] RDMA/cxgb4: Fix neigh reference leak in rx_pkt()

      https://git.kernel.org/rdma/rdma/c/5fb3051aa4611a

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>