diff mbox series

RDMA/core: Validate port number in query_pkey verb

Message ID 20181206124818.4298-1-yuval.shaia@oracle.com (mailing list archive)
State Accepted
Commit 9af3f5cf9d64a056eca53bc643f6288ad28bbbb5
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/core: Validate port number in query_pkey verb | expand

Commit Message

Yuval Shaia Dec. 6, 2018, 12:48 p.m. UTC
Before calling the driver's function let's make sure port is valid.

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
 drivers/infiniband/core/device.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jason Gunthorpe Dec. 7, 2018, 9:33 p.m. UTC | #1
On Thu, Dec 06, 2018 at 02:48:18PM +0200, Yuval Shaia wrote:
> Before calling the driver's function let's make sure port is valid.
> 
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
>  drivers/infiniband/core/device.c | 3 +++
>  1 file changed, 3 insertions(+)

This is the only patch in that last volly that didn't get comments
that look like respins, and I like it so applied to for-next.

Please resend everything else with comments addressed

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 0027b0d79b09..348a7fb1f945 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1042,6 +1042,9 @@  int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb,
 int ib_query_pkey(struct ib_device *device,
 		  u8 port_num, u16 index, u16 *pkey)
 {
+	if (!rdma_is_port_valid(device, port_num))
+		return -EINVAL;
+
 	return device->query_pkey(device, port_num, index, pkey);
 }
 EXPORT_SYMBOL(ib_query_pkey);