Skip to content

Commit 87e0eac

Browse files
Dan Carpenterjgunthorpe
authored andcommitted
RDMA/nldev: Prevent underflow in nldev_stat_set_counter_dynamic_doit()
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>
1 parent 2e11a5e commit 87e0eac

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/infiniband/core/nldev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,9 +1951,10 @@ static int nldev_stat_set_counter_dynamic_doit(struct nlattr *tb[],
19511951
u32 port)
19521952
{
19531953
struct rdma_hw_stats *stats;
1954-
int rem, i, index, ret = 0;
19551954
struct nlattr *entry_attr;
19561955
unsigned long *target;
1956+
int rem, i, ret = 0;
1957+
u32 index;
19571958

19581959
stats = ib_get_hw_stats_port(device, port);
19591960
if (!stats)

0 commit comments

Comments
 (0)