From: Daniel Wagner Date: Wed, 5 Apr 2023 06:37:38 +0000 (+0200) Subject: tree: Fix argument check in nvme_bytes_to_lba X-Git-Tag: v1.5~61 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=01c6055e5602ba22d37c930f504f07ffaaf1df54;p=users%2Fsagi%2Flibnvme.git 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 --- 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; }