diff options
author | 2025-04-12 10:30:17 +0800 | |
---|---|---|
committer | 2025-04-16 19:32:18 -0600 | |
commit | ec120093180b9d92b0c84cb89a205876f9a4cb40 (patch) | |
tree | 4c149c56b39b88efa7fe0c5b74bbc451aeec93df /tools | |
parent | block: integrity: Do not call set_page_dirty_lock() (diff) | |
download | wireguard-linux-ec120093180b9d92b0c84cb89a205876f9a4cb40.tar.xz wireguard-linux-ec120093180b9d92b0c84cb89a205876f9a4cb40.zip |
selftests: ublk: fix ublk_find_tgt()
Bounds check for iterator variable `i` is missed, so add it and fix
ublk_find_tgt().
Cc: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250412023035.2649275-2-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r-- | tools/testing/selftests/ublk/kublk.c | 3 | ||||
-rw-r--r-- | tools/testing/selftests/ublk/kublk.h | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c index 91c282bc7674..74cf70b2f28e 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 < ARRAY_SIZE(tgt_ops_list); i++) if (strcmp(tgt_ops_list[i]->name, name) == 0) return tgt_ops_list[i]; return NULL; diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h index 760ff8ffb810..73294f6e3e49 100644 --- a/tools/testing/selftests/ublk/kublk.h +++ b/tools/testing/selftests/ublk/kublk.h @@ -30,6 +30,8 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #endif +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + /****************** part 1: libublk ********************/ #define CTRL_DEV "/dev/ublk-control" |