All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: kernel-janitors@vger.kernel.org, linux-mtd@lists.infradead.org,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: [patch] UBIFS: use kmalloc_array() in recomp_data_node()
Date: Sat, 17 Nov 2012 15:11:26 +0000	[thread overview]
Message-ID: <20121117151126.GA16900@elgon.mountain> (raw)

Using kmalloc_array() is a cleanup and it includes a check for integer
overflows.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index afaad07..23c2a20 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -1104,7 +1104,7 @@ static int recomp_data_node(struct ubifs_data_node *dn, int *new_len)
 	int err, len, compr_type, out_len;
 
 	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;
 

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: kernel-janitors@vger.kernel.org, linux-mtd@lists.infradead.org,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: [patch] UBIFS: use kmalloc_array() in recomp_data_node()
Date: Sat, 17 Nov 2012 18:11:26 +0300	[thread overview]
Message-ID: <20121117151126.GA16900@elgon.mountain> (raw)

Using kmalloc_array() is a cleanup and it includes a check for integer
overflows.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index afaad07..23c2a20 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -1104,7 +1104,7 @@ static int recomp_data_node(struct ubifs_data_node *dn, int *new_len)
 	int err, len, compr_type, out_len;
 
 	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;
 

             reply	other threads:[~2012-11-17 15:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-17 15:11 Dan Carpenter [this message]
2012-11-17 15:11 ` [patch] UBIFS: use kmalloc_array() in recomp_data_node() Dan Carpenter
2012-11-22 10:31 ` Artem Bityutskiy
2012-11-22 10:31   ` Artem Bityutskiy
2012-11-22 11:14   ` Dan Carpenter
2012-11-22 11:14     ` Dan Carpenter
2012-11-22 11:24     ` Artem Bityutskiy
2012-11-22 11:24       ` Artem Bityutskiy
2012-11-22 12:33       ` Dan Carpenter
2012-11-22 12:33         ` Dan Carpenter
2012-11-22 14:48         ` Artem Bityutskiy
2012-11-22 14:48           ` Artem Bityutskiy
2012-11-22 16:41           ` Dan Carpenter
2012-11-22 16:41             ` Dan Carpenter
2012-11-22 11:26     ` Artem Bityutskiy
2012-11-22 11:26       ` Artem Bityutskiy
2012-11-22 11:29       ` Artem Bityutskiy
2012-11-22 11:29         ` Artem Bityutskiy
2012-11-22 12:09         ` Dan Carpenter
2012-11-22 12:09           ` Dan Carpenter
2012-11-22 11:50       ` Dan Carpenter
2012-11-22 11:50         ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121117151126.GA16900@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=adrian.hunter@intel.com \
    --cc=dedekind1@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.