From 7172423f055834c0730bcc9bcd09d4faa858d46a Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Fri, 26 May 2017 16:10:12 +0200 Subject: [PATCH] ftl: compute length after determining the offset --- source/ftl/ftl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/ftl/ftl.c b/source/ftl/ftl.c index 9f8d1d3..637bbaf 100644 --- a/source/ftl/ftl.c +++ b/source/ftl/ftl.c @@ -28,11 +28,10 @@ size_t ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va) if (!data) return 0; - len = min(len, (1 << map->log2_page_size) - offset); - mask = ((1 << map->log2_page_size) - 1); offset = va & mask; va >>= map->log2_page_size; + len = min(len, (1 << map->log2_page_size) - offset); if ((ret = trace_path(map, NULL, &page, va)) < 0) { memset(data, 0, len);