Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1465080
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc() |
| Date | 2016-08-18 12:10 +0200 |
| Message-ID | <s7sqT-6Jo-57@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <s7shc-6qu-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 18 Aug 2016 11:26:18 +0200
* The script "checkpatch.pl" can point information out like the following.
WARNING: Prefer kcalloc over kzalloc with multiply
Thus fix the affected source code places.
* Replace the specification of data structures by pointer dereferences
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/block/cciss.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b08bfb7..3502a3a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1604,12 +1604,12 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
status = -EINVAL;
goto free_ioc;
}
- buff_size = kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL);
+ buff_size = kcalloc(MAXSGENTRIES, sizeof(*buff_size), GFP_KERNEL);
if (!buff_size) {
status = -ENOMEM;
goto free_ioc;
}
- buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
+ buff = kcalloc(MAXSGENTRIES, sizeof(*buff), GFP_KERNEL);
if (!buff) {
status = -ENOMEM;
goto free_size;
@@ -4838,8 +4838,9 @@ static int cciss_allocate_scatterlists(ctlr_info_t *h)
int i;
/* zero it, so that on free we need not know how many were alloc'ed */
- h->scatter_list = kzalloc(h->max_commands *
- sizeof(struct scatterlist *), GFP_KERNEL);
+ h->scatter_list = kcalloc(h->max_commands,
+ sizeof(*h->scatter_list),
+ GFP_KERNEL);
if (!h->scatter_list)
return -ENOMEM;
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:00 +0200 [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:00 +0200 [PATCH 2/5] block-cciss: Less function calls in cciss_bigpassthru() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:00 +0200 [PATCH 3/5] block-cciss: Delete unnecessary initialisations in cciss_bigpassthru() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:10 +0200 [PATCH 4/5] block-cciss: Move an assignment for the variable "sg_used" in cciss_bigpassthru() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:10 +0200 [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:10 +0200
csiph-web