summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2018-02-06 18:39:51 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-06 21:32:46 -0500
commitd1509c097f685472fb8c6b510ae8c8678499e53d (patch)
tree40f350ce5fb6b92a07be9998766f0ac04a3aaa31
parente1d66d042187f7f18a50fab83cbc9b21b183cc7c (diff)
rapidio: improve a size determination in five functions
Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Link: http://lkml.kernel.org/r/495f571c-fb4d-b1d5-a6e5-494f2c537a8d@users.sourceforge.net Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Acked-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rapidio/rio.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index b9dc932ce19e..90534365e46c 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -110,9 +110,8 @@ EXPORT_SYMBOL(rio_query_mport);
110 */ 110 */
111struct rio_net *rio_alloc_net(struct rio_mport *mport) 111struct rio_net *rio_alloc_net(struct rio_mport *mport)
112{ 112{
113 struct rio_net *net; 113 struct rio_net *net = kzalloc(sizeof(*net), GFP_KERNEL);
114 114
115 net = kzalloc(sizeof(struct rio_net), GFP_KERNEL);
116 if (net) { 115 if (net) {
117 INIT_LIST_HEAD(&net->node); 116 INIT_LIST_HEAD(&net->node);
118 INIT_LIST_HEAD(&net->devices); 117 INIT_LIST_HEAD(&net->devices);
@@ -246,8 +245,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,
246 if (!mport->ops->open_inb_mbox) 245 if (!mport->ops->open_inb_mbox)
247 goto out; 246 goto out;
248 247
249 res = kzalloc(sizeof(struct resource), GFP_KERNEL); 248 res = kzalloc(sizeof(*res), GFP_KERNEL);
250
251 if (res) { 249 if (res) {
252 rio_init_mbox_res(res, mbox, mbox); 250 rio_init_mbox_res(res, mbox, mbox);
253 251
@@ -329,8 +327,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,
329 if (!mport->ops->open_outb_mbox) 327 if (!mport->ops->open_outb_mbox)
330 goto out; 328 goto out;
331 329
332 res = kzalloc(sizeof(struct resource), GFP_KERNEL); 330 res = kzalloc(sizeof(*res), GFP_KERNEL);
333
334 if (res) { 331 if (res) {
335 rio_init_mbox_res(res, mbox, mbox); 332 rio_init_mbox_res(res, mbox, mbox);
336 333
@@ -445,8 +442,7 @@ int rio_request_inb_dbell(struct rio_mport *mport,
445 u16 dst, u16 info)) 442 u16 dst, u16 info))
446{ 443{
447 int rc = 0; 444 int rc = 0;
448 445 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
449 struct resource *res = kzalloc(sizeof(struct resource), GFP_KERNEL);
450 446
451 if (res) { 447 if (res) {
452 rio_init_dbell_res(res, start, end); 448 rio_init_dbell_res(res, start, end);
@@ -568,9 +564,8 @@ int rio_add_mport_pw_handler(struct rio_mport *mport, void *context,
568 void *context, union rio_pw_msg *msg, int step)) 564 void *context, union rio_pw_msg *msg, int step))
569{ 565{
570 int rc = 0; 566 int rc = 0;
571 struct rio_pwrite *pwrite; 567 struct rio_pwrite *pwrite = kzalloc(sizeof(*pwrite), GFP_KERNEL);
572 568
573 pwrite = kzalloc(sizeof(struct rio_pwrite), GFP_KERNEL);
574 if (!pwrite) { 569 if (!pwrite) {
575 rc = -ENOMEM; 570 rc = -ENOMEM;
576 goto out; 571 goto out;