On 07.04.25 15:18, Ming Lei wrote: > Bounds check for iterator variable `i` is missed, so add it and fix > ublk_find_tgt(). > > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> > --- > tools/testing/selftests/ublk/kublk.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c > index 91c282bc7674..5c03c776426f 100644 > --- a/tools/testing/selftests/ublk/kublk.c > +++ b/tools/testing/selftests/ublk/kublk.c > @@ -14,13 +14,12 @@ static const struct ublk_tgt_ops *tgt_ops_list[] = { > > static const struct ublk_tgt_ops *ublk_find_tgt(const char *name) > { > - const struct ublk_tgt_ops *ops; > int i; > > if (name == NULL) > return NULL; > > - for (i = 0; sizeof(tgt_ops_list) / sizeof(ops); i++) > + for (i = 0; i < sizeof(tgt_ops_list) / sizeof(tgt_ops_list[0]); i++) Why not for (i=0; i < ARRAY_SIZE(tgt_ops_list); i++)