All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/mlx5: add checking for "vf" from do_setvfinfo()
@ 2019-04-12 17:55 Dan Carpenter
  2019-04-12 20:25 ` Parav Pandit
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Dan Carpenter @ 2019-04-12 17:55 UTC (permalink / raw)
  To: kernel-janitors

My static checker complains that these "vf" variables come from the
user in do_setvfinfo() and haven't been checked to make sure they're
valid.

Fixes: eff901d30e6c ("IB/mlx5: Implement callbacks for manipulating VFs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Untested static checker stuff.  Please review carefully.

 drivers/infiniband/hw/mlx5/ib_virt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/infiniband/hw/mlx5/ib_virt.c b/drivers/infiniband/hw/mlx5/ib_virt.c
index 649a3364f838..9a8eebe3d462 100644
--- a/drivers/infiniband/hw/mlx5/ib_virt.c
+++ b/drivers/infiniband/hw/mlx5/ib_virt.c
@@ -56,6 +56,9 @@ int mlx5_ib_get_vf_config(struct ib_device *device, int vf, u8 port,
 	struct mlx5_hca_vport_context *rep;
 	int err;
 
+	if (vf < 0 || vf >= pci_sriov_get_totalvfs(mdev->pdev))
+		return -EINVAL;
+
 	rep = kzalloc(sizeof(*rep), GFP_KERNEL);
 	if (!rep)
 		return -ENOMEM;
@@ -99,6 +102,9 @@ int mlx5_ib_set_vf_link_state(struct ib_device *device, int vf,
 	struct mlx5_vf_context *vfs_ctx = mdev->priv.sriov.vfs_ctx;
 	int err;
 
+	if (vf < 0 || vf >= pci_sriov_get_totalvfs(mdev->pdev))
+		return -EINVAL;
+
 	in = kzalloc(sizeof(*in), GFP_KERNEL);
 	if (!in)
 		return -ENOMEM;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-09-25 17:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 17:55 [PATCH] IB/mlx5: add checking for "vf" from do_setvfinfo() Dan Carpenter
2019-04-12 20:25 ` Parav Pandit
2019-04-15  9:32 ` Dan Carpenter
2019-04-15  9:46 ` Dan Carpenter
2019-04-15 20:04 ` Parav Pandit
2019-04-16  8:21 ` Dan Carpenter
2019-04-16 22:54 ` Parav Pandit
2019-04-22  8:08 ` Dan Carpenter
2019-04-22 15:09 ` Parav Pandit
2019-04-23 15:49 ` Dan Carpenter
2019-04-23 22:32 ` Parav Pandit
2019-04-24 14:08   ` Dan Carpenter
2019-04-24 14:08     ` Dan Carpenter
2019-04-24 14:24     ` Jason Gunthorpe
2019-04-24 14:24       ` Jason Gunthorpe
2019-04-24 22:12       ` Parav Pandit
2019-04-25  0:36     ` Jakub Kicinski
2019-04-25  0:36       ` Jakub Kicinski
2019-04-25  6:15     ` Parav Pandit
2019-09-24  9:21       ` Dan Carpenter
2019-09-24  9:21         ` Dan Carpenter
2019-09-25 17:14         ` Parav Pandit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.