]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: Fix argument check in nvme_bytes_to_lba
authorDaniel Wagner <dwagner@suse.de>
Wed, 5 Apr 2023 06:37:38 +0000 (08:37 +0200)
committerDaniel Wagner <wagi@monom.org>
Wed, 5 Apr 2023 07:21:44 +0000 (09:21 +0200)
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 <dwagner@suse.de>
src/nvme/tree.c

index 34844634f231d7c77bf586bb6ac824c9f41fe9b7..6b584831278cd331df9831256c2a0595cd7e6206 100644 (file)
@@ -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;
        }