* [PATCH] ubifs: Use kmalloc_array()
@ 2018-07-02 21:47 Richard Weinberger
2018-07-02 21:48 ` Kees Cook
0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2018-07-02 21:47 UTC (permalink / raw)
To: linux-mtd; +Cc: linux-kernel, Richard Weinberger, Kees Cook
Since commit 6da2ec56059c ("treewide: kmalloc() -> kmalloc_array()")
we use kmalloc_array() for kmalloc() that computes the length with
a multiplication.
Cc: Kees Cook <keescook@chromium.org>
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
fs/ubifs/journal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index eea12d25a58b..95acc0c04bca 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -1285,7 +1285,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
int err, dlen, compr_type, out_len, old_dlen;
out_len = le32_to_cpu(dn->size);
- buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
+ buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
if (!buf)
return -ENOMEM;
--
2.18.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ubifs: Use kmalloc_array()
2018-07-02 21:47 [PATCH] ubifs: Use kmalloc_array() Richard Weinberger
@ 2018-07-02 21:48 ` Kees Cook
0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2018-07-02 21:48 UTC (permalink / raw)
To: Richard Weinberger; +Cc: Linux mtd, LKML
On Mon, Jul 2, 2018 at 2:47 PM, Richard Weinberger <richard@nod.at> wrote:
> Since commit 6da2ec56059c ("treewide: kmalloc() -> kmalloc_array()")
> we use kmalloc_array() for kmalloc() that computes the length with
> a multiplication.
>
> Cc: Kees Cook <keescook@chromium.org>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Kees Cook <keescook@chromium.org>
Thanks!
-Kees
> ---
> fs/ubifs/journal.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index eea12d25a58b..95acc0c04bca 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -1285,7 +1285,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
> int err, dlen, compr_type, out_len, old_dlen;
>
> out_len = le32_to_cpu(dn->size);
> - buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
> + buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
> if (!buf)
> return -ENOMEM;
>
> --
> 2.18.0
>
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-02 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02 21:47 [PATCH] ubifs: Use kmalloc_array() Richard Weinberger
2018-07-02 21:48 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®