2014-06-23 16:42:42

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 1/1] fs/ubifs/super.c: replace count*size kzalloc by kcalloc

kcalloc manages count*sizeof overflow.

Cc: Artem Bityutskiy <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: [email protected]
Signed-off-by: Fabian Frederick <[email protected]>
---
fs/ubifs/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 3904c85..537b91d 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -796,8 +796,8 @@ static int alloc_wbufs(struct ubifs_info *c)
{
int i, err;

- c->jheads = kzalloc(c->jhead_cnt * sizeof(struct ubifs_jhead),
- GFP_KERNEL);
+ c->jheads = kcalloc(c->jhead_cnt, sizeof(struct ubifs_jhead),
+ GFP_KERNEL);
if (!c->jheads)
return -ENOMEM;

--
1.8.4.5


2014-07-16 06:10:44

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH 1/1] fs/ubifs/super.c: replace count*size kzalloc by kcalloc

On Mon, 2014-06-23 at 18:41 +0200, Fabian Frederick wrote:
> kcalloc manages count*sizeof overflow.
>
> Cc: Artem Bityutskiy <[email protected]>
> Cc: Adrian Hunter <[email protected]>
> Cc: [email protected]
> Signed-off-by: Fabian Frederick <[email protected]>

In the commit message, please, try to not only tell _what_ you do,
but also _why_ you do this. And ideally, but not necessary for this
case, I think, how this was tested (e.g., compile-tested only).

Thanks! I'll apply this patch, and amend the commit message so that it
tells that kcalloc() makes better bob of the overflow checking.

--
Best Regards,
Artem Bityutskiy

2014-07-16 06:17:29

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH 1/1] fs/ubifs/super.c: replace count*size kzalloc by kcalloc

On Wed, 2014-07-16 at 09:10 +0300, Artem Bityutskiy wrote:
> On Mon, 2014-06-23 at 18:41 +0200, Fabian Frederick wrote:
> > kcalloc manages count*sizeof overflow.
> >
> > Cc: Artem Bityutskiy <[email protected]>
> > Cc: Adrian Hunter <[email protected]>
> > Cc: [email protected]
> > Signed-off-by: Fabian Frederick <[email protected]>
>
> In the commit message, please, try to not only tell _what_ you do,
> but also _why_ you do this. And ideally, but not necessary for this
> case, I think, how this was tested (e.g., compile-tested only).

Oh, I'm sorry, you did tell "why" in this patch, I was looking an the a
different patch of yours (seq_printf). I've applied this patch to
linux-ubifs.git, thanks!

--
Best Regards,
Artem Bityutskiy