Skip to content

Commit

Permalink
RDMA/nldev: Prevent underflow in nldev_stat_set_counter_dynamic_doit()
Browse files Browse the repository at this point in the history
This code checks "index" for an upper bound but it does not check for
negatives.  Change the type to unsigned to prevent underflows.

Fixes: 3c3c1f1 ("RDMA/nldev: Allow optional-counter status configuration through RDMA netlink")
Link: https://lore.kernel.org/r/20220316083948.GC30941@kili
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
  • Loading branch information
Dan Carpenter authored and Jason Gunthorpe committed Mar 18, 2022
1 parent 2e11a5e commit 87e0eac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/infiniband/core/nldev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1951,9 +1951,10 @@ static int nldev_stat_set_counter_dynamic_doit(struct nlattr *tb[],
u32 port)
{
struct rdma_hw_stats *stats;
int rem, i, index, ret = 0;
struct nlattr *entry_attr;
unsigned long *target;
int rem, i, ret = 0;
u32 index;

stats = ib_get_hw_stats_port(device, port);
if (!stats)
Expand Down

0 comments on commit 87e0eac

Please sign in to comment.