dm-cache-target: check for allocation failure
Subsystems (3)
PATCH 1/1 dm-cache-target: check for allocation failure
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 <[email protected]>
---
I expect that kbuild will complain about this soon?
drivers/md/dm-cache-target.c +4 -1
@@ -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]) {
Alasdair G Kergon
maintainerQuoted 3 lines · Dan Carpenter
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