mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-01 15:14:52 +00:00
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>
This commit is contained in:
parent
39e1605051
commit
ec12009318
@ -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;
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user