* [PATCH] Btrfs: use correct args for kcalloc in btrfsic_read_block
@ 2018-09-07 17:59 Liu Bo
2018-09-07 18:21 ` Omar Sandoval
2018-09-07 20:41 ` [PATCH v2] " Liu Bo
0 siblings, 2 replies; 4+ messages in thread
From: Liu Bo @ 2018-09-07 17:59 UTC (permalink / raw)
To: linux-btrfs
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()
has switched n with size.
This updates btrfsic_read_block() to be correct in using kcalloc.
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
---
fs/btrfs/check-integrity.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 833cf3c35b4d..651b75939ce9 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1594,6 +1594,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
{
unsigned int num_pages;
unsigned int i;
+ u64 size;
u64 dev_bytenr;
int ret;
@@ -1608,9 +1609,8 @@ static int btrfsic_read_block(struct btrfsic_state *state,
num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
PAGE_SHIFT;
- block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) +
- sizeof(*block_ctx->pagev),
- num_pages, GFP_NOFS);
+ size = sizeof(*block_ctx->datav) + sizeof(*block_ctx->pagev);
+ block_ctx->mem_to_free = kcalloc(num_pages, size, GFP_NOFS);
if (!block_ctx->mem_to_free)
return -ENOMEM;
block_ctx->datav = block_ctx->mem_to_free;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: use correct args for kcalloc in btrfsic_read_block
2018-09-07 17:59 [PATCH] Btrfs: use correct args for kcalloc in btrfsic_read_block Liu Bo
@ 2018-09-07 18:21 ` Omar Sandoval
2018-09-07 18:50 ` Liu Bo
2018-09-07 20:41 ` [PATCH v2] " Liu Bo
1 sibling, 1 reply; 4+ messages in thread
From: Omar Sandoval @ 2018-09-07 18:21 UTC (permalink / raw)
To: Liu Bo; +Cc: linux-btrfs
On Sat, Sep 08, 2018 at 01:59:50AM +0800, Liu Bo wrote:
> 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()
> has switched n with size.
>
> This updates btrfsic_read_block() to be correct in using kcalloc.
>
> Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
> ---
> fs/btrfs/check-integrity.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 833cf3c35b4d..651b75939ce9 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -1594,6 +1594,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
> {
> unsigned int num_pages;
> unsigned int i;
> + u64 size;
size_t?
Besides that, Reviewed-by: Omar Sandoval <osandov@fb.com>
> u64 dev_bytenr;
> int ret;
>
> @@ -1608,9 +1609,8 @@ static int btrfsic_read_block(struct btrfsic_state *state,
>
> num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
> PAGE_SHIFT;
> - block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) +
> - sizeof(*block_ctx->pagev),
> - num_pages, GFP_NOFS);
> + size = sizeof(*block_ctx->datav) + sizeof(*block_ctx->pagev);
> + block_ctx->mem_to_free = kcalloc(num_pages, size, GFP_NOFS);
> if (!block_ctx->mem_to_free)
> return -ENOMEM;
> block_ctx->datav = block_ctx->mem_to_free;
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: use correct args for kcalloc in btrfsic_read_block
2018-09-07 18:21 ` Omar Sandoval
@ 2018-09-07 18:50 ` Liu Bo
0 siblings, 0 replies; 4+ messages in thread
From: Liu Bo @ 2018-09-07 18:50 UTC (permalink / raw)
To: Omar Sandoval; +Cc: Liu Bo, linux-btrfs
On Fri, Sep 7, 2018 at 11:21 AM, Omar Sandoval <osandov@osandov.com> wrote:
> On Sat, Sep 08, 2018 at 01:59:50AM +0800, Liu Bo wrote:
>> 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()
>> has switched n with size.
>>
>> This updates btrfsic_read_block() to be correct in using kcalloc.
>>
>> Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
>> ---
>> fs/btrfs/check-integrity.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
>> index 833cf3c35b4d..651b75939ce9 100644
>> --- a/fs/btrfs/check-integrity.c
>> +++ b/fs/btrfs/check-integrity.c
>> @@ -1594,6 +1594,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
>> {
>> unsigned int num_pages;
>> unsigned int i;
>> + u64 size;
>
> size_t?
>
oops, will update it.
thanks,
liubo
> Besides that, Reviewed-by: Omar Sandoval <osandov@fb.com>
>
>> u64 dev_bytenr;
>> int ret;
>>
>> @@ -1608,9 +1609,8 @@ static int btrfsic_read_block(struct btrfsic_state *state,
>>
>> num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
>> PAGE_SHIFT;
>> - block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) +
>> - sizeof(*block_ctx->pagev),
>> - num_pages, GFP_NOFS);
>> + size = sizeof(*block_ctx->datav) + sizeof(*block_ctx->pagev);
>> + block_ctx->mem_to_free = kcalloc(num_pages, size, GFP_NOFS);
>> if (!block_ctx->mem_to_free)
>> return -ENOMEM;
>> block_ctx->datav = block_ctx->mem_to_free;
>> --
>> 1.8.3.1
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] Btrfs: use correct args for kcalloc in btrfsic_read_block
2018-09-07 17:59 [PATCH] Btrfs: use correct args for kcalloc in btrfsic_read_block Liu Bo
2018-09-07 18:21 ` Omar Sandoval
@ 2018-09-07 20:41 ` Liu Bo
1 sibling, 0 replies; 4+ messages in thread
From: Liu Bo @ 2018-09-07 20:41 UTC (permalink / raw)
To: linux-btrfs
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()
has switched n with size.
This updates btrfsic_read_block() to be correct in using kcalloc.
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
---
v2: use size_t to be consistent with kcalloc()'s prototype.
fs/btrfs/check-integrity.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 833cf3c35b4d..2e43fba44035 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1594,6 +1594,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
{
unsigned int num_pages;
unsigned int i;
+ size_t size;
u64 dev_bytenr;
int ret;
@@ -1608,9 +1609,8 @@ static int btrfsic_read_block(struct btrfsic_state *state,
num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
PAGE_SHIFT;
- block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) +
- sizeof(*block_ctx->pagev),
- num_pages, GFP_NOFS);
+ size = sizeof(*block_ctx->datav) + sizeof(*block_ctx->pagev);
+ block_ctx->mem_to_free = kcalloc(num_pages, size, GFP_NOFS);
if (!block_ctx->mem_to_free)
return -ENOMEM;
block_ctx->datav = block_ctx->mem_to_free;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-08 1:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07 17:59 [PATCH] Btrfs: use correct args for kcalloc in btrfsic_read_block Liu Bo
2018-09-07 18:21 ` Omar Sandoval
2018-09-07 18:50 ` Liu Bo
2018-09-07 20:41 ` [PATCH v2] " Liu Bo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.