Skip to contentSkip to conversation

RDMA/nldev: Reshuffle the code to avoid need to rebind QP in error path

PATCH Applied Leon Romanovsky 2 participants 2 messages Oct 2, 2019 – Oct 4, 2019 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/nldev: Reshuffle the code to avoid need to rebind QP in error path

From: Leon Romanovsky <[email protected]>

Properly unwind QP counter rebinding in case of failure.

Fixes b389327df905 ("RDMA/nldev: Allow counter manual mode configration through RDMA netlink")

---
Changelog v0->v1: https://lore.kernel.org/linux-rdma/[email protected]
* Used different goto label.

---
 drivers/infiniband/core/nldev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/infiniband/core/nldev.c +4 -6
index 7a7474000100..068ac0719ca5 100644
@@ -1787,10 +1787,6 @@ static int nldev_stat_del_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	cntn = nla_get_u32(tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID]);
 	qpn = nla_get_u32(tb[RDMA_NLDEV_ATTR_RES_LQPN]);
-	ret = rdma_counter_unbind_qpn(device, port, qpn, cntn);
-	if (ret)
-		goto err_unbind;
-
 	if (fill_nldev_handle(msg, device) ||
 	    nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, port) ||
 	    nla_put_u32(msg, RDMA_NLDEV_ATTR_STAT_COUNTER_ID, cntn) ||
@@ -1799,13 +1795,15 @@ static int nldev_stat_del_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
 		goto err_fill;
 	}
 
+	ret = rdma_counter_unbind_qpn(device, port, qpn, cntn);
+	if (ret)
+		goto err_fill;
+
 	nlmsg_end(msg, nlh);
 	ib_device_put(device);
 	return rdma_nl_unicast(sock_net(skb->sk), msg, NETLINK_CB(skb).portid);
 
 err_fill:
-	rdma_counter_bind_qpn(device, port, qpn, cntn);
-err_unbind:
 	nlmsg_free(msg);
 err:
 	ib_device_put(device);

--
2.20.1

#1 lore raw
Quoted 7 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Properly unwind QP counter rebinding in case of failure.

Fixes b389327df905 ("RDMA/nldev: Allow counter manual mode configration through RDMA netlink")
Quoted 6 lines

---
Changelog v0->v1: https://lore.kernel.org/linux-rdma/[email protected]
* Used different goto label.

---
 drivers/infiniband/core/nldev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Applied to for-next, thanks

Jason