From 01c6055e5602ba22d37c930f504f07ffaaf1df54 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 5 Apr 2023 08:37:38 +0200 Subject: [PATCH] tree: Fix argument check in nvme_bytes_to_lba nvme_bytes_to_lba() argument checker is ensuring that all passed in values are valid. That means we have at least one block to write, the offset is aligned to a block starting address and the number of blocks is a multiple of the block size The last check is wrong, thus fix it. Signed-off-by: Daniel Wagner --- src/nvme/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvme/tree.c b/src/nvme/tree.c index 34844634..6b584831 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -1481,7 +1481,7 @@ static int nvme_bytes_to_lba(nvme_ns_t n, off_t offset, size_t count, int bs; bs = nvme_ns_get_lba_size(n); - if (!count || offset & bs || count & bs) { + if (!count || offset & bs || count & (bs - 1)) { errno = EINVAL; return -1; } -- 2.50.1