Skip to contentSkip to conversation

RDMA/counter: Prevent QP counter binding if counters unsupported

PATCH In review Leon Romanovsky 2 participants 2 messages Aug 7, 2019 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/counter: Prevent QP counter binding if counters unsupported

From: Mark Zhang <[email protected]>

In case of rdma_counter_init() fails, counter allocation and QP bind should not be allowed.

Fixes 413d3347503b ("RDMA/counter: Add set/clear per-port auto mode support")
Fixes 1bd8e0a9d0fd ("RDMA/counter: Allow manual mode configuration support")
---
 drivers/infiniband/core/counters.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/infiniband/core/counters.c +6 -0
index 45d5164e9574..b79890739a2c 100644
@@ -38,6 +38,9 @@ int rdma_counter_set_auto_mode(struct ib_device *dev, u8 port,
 	int ret;
 
 	port_counter = &dev->port_data[port].port_counter;
+	if (!port_counter->hstats)
+		return -EOPNOTSUPP;
+
 	mutex_lock(&port_counter->lock);
 	if (on) {
 		ret = __counter_set_mode(&port_counter->mode,
@@ -509,6 +512,9 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port,
 	if (!rdma_is_port_valid(dev, port))
 		return -EINVAL;
 
+	if (!dev->port_data[port].port_counter.hstats)
+		return -EOPNOTSUPP;
+
 	qp = rdma_counter_get_qp(dev, qp_num);
 	if (!qp)
 		return -ENOENT;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 5 lines · Leon Romanovsky

From: Mark Zhang <[email protected]>

In case of rdma_counter_init() fails, counter allocation and QP bind should not be allowed.

Quoted 7 lines
Fixes 413d3347503b ("RDMA/counter: Add set/clear per-port auto mode

support")

Fixes 1bd8e0a9d0fd ("RDMA/counter: Allow manual mode configuration

support")

Looks good, applied to for-rc, thanks.

Signature · 3 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD