* [patch] dm-cache-target: check for allocation failure
@ 2013-03-01 20:26 Dan Carpenter
2013-03-01 21:36 ` [dm-devel] " Alasdair G Kergon
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2013-03-01 20:26 UTC (permalink / raw)
To: Alasdair Kergon; +Cc: dm-devel, Neil Brown, linux-raid, kernel-janitors, kbuild
The allocation here isn't checked. I changed it to using kcalloc()
as a cleanup. It adds integer overflow checking as well which makes
the code easier to audit.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I expect that kbuild will complain about this soon?
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 908d554..40753b4 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -1957,8 +1957,11 @@ bad:
static int copy_ctr_args(struct cache *cache, int argc, const char **argv)
{
unsigned i;
- const char **copy = kzalloc(sizeof(*copy) * argc, GFP_KERNEL);
+ const char **copy;
+ copy = kcalloc(argc, sizeof(*copy), GFP_KERNEL);
+ if (!copy)
+ return -ENOMEM;
for (i = 0; i < argc; i++) {
copy[i] = kstrdup(argv[i], GFP_KERNEL);
if (!copy[i]) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [dm-devel] [patch] dm-cache-target: check for allocation failure
2013-03-01 20:26 [patch] dm-cache-target: check for allocation failure Dan Carpenter
@ 2013-03-01 21:36 ` Alasdair G Kergon
0 siblings, 0 replies; 2+ messages in thread
From: Alasdair G Kergon @ 2013-03-01 21:36 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alasdair Kergon, linux-raid, dm-devel, kbuild, kernel-janitors
On Fri, Mar 01, 2013 at 11:26:41PM +0300, Dan Carpenter wrote:
> The allocation here isn't checked. I changed it to using kcalloc()
> as a cleanup. It adds integer overflow checking as well which makes
> the code easier to audit.
Folded it in - thanks.
Alasdair
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-01 21:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-01 20:26 [patch] dm-cache-target: check for allocation failure Dan Carpenter
2013-03-01 21:36 ` [dm-devel] " Alasdair G Kergon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).