提交 3b2fd801 编写于 作者: L Liu Bo 提交者: David Sterba

Btrfs: use args in the correct order for kcalloc in btrfsic_read_block

kcalloc is defined as:

  kcalloc(size_t n, size_t size, gfp_t flags)

Although this won't cause problems in practice, btrfsic_read_block()
uses kcalloc with n and size in the opposite order.
Reviewed-by: NOmar Sandoval <osandov@fb.com>
Signed-off-by: NLiu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 a27a94c2
...@@ -1594,6 +1594,7 @@ static int btrfsic_read_block(struct btrfsic_state *state, ...@@ -1594,6 +1594,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
{ {
unsigned int num_pages; unsigned int num_pages;
unsigned int i; unsigned int i;
size_t size;
u64 dev_bytenr; u64 dev_bytenr;
int ret; int ret;
...@@ -1608,9 +1609,8 @@ static int btrfsic_read_block(struct btrfsic_state *state, ...@@ -1608,9 +1609,8 @@ static int btrfsic_read_block(struct btrfsic_state *state,
num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >> num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
PAGE_SHIFT; PAGE_SHIFT;
block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) + size = sizeof(*block_ctx->datav) + sizeof(*block_ctx->pagev);
sizeof(*block_ctx->pagev), block_ctx->mem_to_free = kcalloc(num_pages, size, GFP_NOFS);
num_pages, GFP_NOFS);
if (!block_ctx->mem_to_free) if (!block_ctx->mem_to_free)
return -ENOMEM; return -ENOMEM;
block_ctx->datav = block_ctx->mem_to_free; block_ctx->datav = block_ctx->mem_to_free;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册