Fix some problems found by Coverity scan.
[platform/upstream/cryptsetup.git] / lib / utils_benchmark.c
index 4ee0c03..f392382 100644 (file)
@@ -128,9 +128,14 @@ static int cipher_perf(struct cipher_perf *cp,
 {
        long ms_enc, ms_dec, ms;
        int repeat_enc, repeat_dec;
+       size_t alignment;
        void *buf = NULL;
 
-       if (posix_memalign(&buf, crypt_getpagesize(), cp->buffer_size))
+       alignment = crypt_getpagesize();
+       if (alignment < 0)
+               return -EINVAL;
+
+       if (posix_memalign(&buf, alignment, cp->buffer_size))
                return -ENOMEM;
 
        ms_enc = 0;