All of lore.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	David Ahern
	<dsa-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>,
	Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Feras Daoud <ferasda-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Hal Rosenstock
	<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Paolo Abeni <pabeni-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Roi Dayan <roid-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>,
	Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 6/9] IB/iser: Use kmalloc_array() in iser_alloc_rx_descriptors()
Date: Fri, 7 Apr 2017 23:06:25 +0200	[thread overview]
Message-ID: <75e5726b-d75f-1b79-1242-08f6440e1691@users.sourceforge.net> (raw)
In-Reply-To: <ce4249f2-c7e7-0282-2cff-3f9c3991efa3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 7 Apr 2017 21:23:29 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/ulp/iser/iser_initiator.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 81ae2e30dd12..6c48bdc8a64d 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -257,8 +257,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
 		goto alloc_login_buf_fail;
 
 	iser_conn->num_rx_descs = session->cmds_max;
-	iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs *
-				sizeof(struct iser_rx_desc), GFP_KERNEL);
+	iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs,
+					    sizeof(*iser_conn->rx_descs),
+					    GFP_KERNEL);
 	if (!iser_conn->rx_descs)
 		goto rx_desc_alloc_fail;
 
-- 
2.12.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
	David Ahern <dsa@cumulusnetworks.com>,
	Doug Ledford <dledford@redhat.com>,
	Erez Shitrit <erezsh@mellanox.com>,
	Feras Daoud <ferasda@mellanox.com>,
	Hal Rosenstock <hal.rosenstock@gmail.com>,
	Leon Romanovsky <leon@kernel.org>,
	Mark Bloch <markb@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Paolo Abeni <pabeni@redhat.com>, Roi Dayan <roid@mellanox.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Sean Hefty <sean.hefty@intel.com>,
	Yuval Shaia <yuval.shaia@oracle.com>,
	Zhu Yanjun <yanjun.zhu@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 6/9] IB/iser: Use kmalloc_array() in iser_alloc_rx_descriptors()
Date: Fri, 7 Apr 2017 23:06:25 +0200	[thread overview]
Message-ID: <75e5726b-d75f-1b79-1242-08f6440e1691@users.sourceforge.net> (raw)
In-Reply-To: <ce4249f2-c7e7-0282-2cff-3f9c3991efa3@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 7 Apr 2017 21:23:29 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of a data structure by a pointer dereference
  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/infiniband/ulp/iser/iser_initiator.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 81ae2e30dd12..6c48bdc8a64d 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -257,8 +257,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
 		goto alloc_login_buf_fail;
 
 	iser_conn->num_rx_descs = session->cmds_max;
-	iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs *
-				sizeof(struct iser_rx_desc), GFP_KERNEL);
+	iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs,
+					    sizeof(*iser_conn->rx_descs),
+					    GFP_KERNEL);
 	if (!iser_conn->rx_descs)
 		goto rx_desc_alloc_fail;
 
-- 
2.12.2

WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	David Ahern
	<dsa-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>,
	Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Feras Daoud <ferasda-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Hal Rosenstock
	<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Paolo Abeni <pabeni-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Roi Dayan <roid-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>,
	Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 6/9] IB/iser: Use kmalloc_array() in iser_alloc_rx_descriptors()
Date: Fri, 07 Apr 2017 21:06:25 +0000	[thread overview]
Message-ID: <75e5726b-d75f-1b79-1242-08f6440e1691@users.sourceforge.net> (raw)
In-Reply-To: <ce4249f2-c7e7-0282-2cff-3f9c3991efa3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 7 Apr 2017 21:23:29 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of a data structure by a pointer dereference
  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/infiniband/ulp/iser/iser_initiator.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 81ae2e30dd12..6c48bdc8a64d 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -257,8 +257,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
 		goto alloc_login_buf_fail;
 
 	iser_conn->num_rx_descs = session->cmds_max;
-	iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs *
-				sizeof(struct iser_rx_desc), GFP_KERNEL);
+	iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs,
+					    sizeof(*iser_conn->rx_descs),
+					    GFP_KERNEL);
 	if (!iser_conn->rx_descs)
 		goto rx_desc_alloc_fail;
 
-- 
2.12.2


  parent reply	other threads:[~2017-04-07 21:06 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 20:54 [PATCH 0/9] InfiniBand-ULP: Fine-tuning for several function implementations SF Markus Elfring
2017-04-07 20:54 ` SF Markus Elfring
2017-04-07 20:54 ` SF Markus Elfring
2017-04-07 20:57 ` [PATCH 1/9] IB/IPoIB: Use kcalloc() in two functions SF Markus Elfring
2017-04-07 20:57   ` SF Markus Elfring
2017-04-09 12:26   ` Sagi Grimberg
2017-04-09 12:26     ` Sagi Grimberg
     [not found] ` <ce4249f2-c7e7-0282-2cff-3f9c3991efa3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-07 21:00   ` [PATCH 2/9] IB/IPoIB: Delete an error message for a failed memory allocation SF Markus Elfring
2017-04-07 21:00     ` SF Markus Elfring
2017-04-07 21:00     ` SF Markus Elfring
2017-04-09 12:26     ` Sagi Grimberg
2017-04-09 12:26       ` Sagi Grimberg
2017-04-07 21:03   ` [PATCH 4/9] IB/IPoIB: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring
2017-04-07 21:03     ` SF Markus Elfring
2017-04-07 21:03     ` SF Markus Elfring
2017-04-09 12:26     ` Sagi Grimberg
2017-04-09 12:26       ` Sagi Grimberg
2017-04-07 21:06   ` SF Markus Elfring [this message]
2017-04-07 21:06     ` [PATCH 6/9] IB/iser: Use kmalloc_array() in iser_alloc_rx_descriptors() SF Markus Elfring
2017-04-07 21:06     ` SF Markus Elfring
     [not found]     ` <75e5726b-d75f-1b79-1242-08f6440e1691-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-09  9:01       ` Sagi Grimberg
2017-04-09  9:01         ` Sagi Grimberg
2017-04-09  9:01         ` Sagi Grimberg
2017-04-07 21:08   ` [PATCH 8/9] IB/isert: Use kcalloc() in isert_alloc_rx_descriptors() SF Markus Elfring
2017-04-07 21:08     ` SF Markus Elfring
2017-04-07 21:08     ` SF Markus Elfring
2017-04-09  9:02     ` Sagi Grimberg
2017-04-09  9:02       ` Sagi Grimberg
2017-04-07 21:01 ` [PATCH 3/9] IB/IPoIB: Enclose six expressions for the sizeof operator by parentheses SF Markus Elfring
2017-04-07 21:01   ` SF Markus Elfring
2017-04-09 12:26   ` Sagi Grimberg
2017-04-09 12:26     ` Sagi Grimberg
2017-04-07 21:05 ` [PATCH 5/9] IB/IPoIB: Combine substrings for three messages SF Markus Elfring
2017-04-07 21:05   ` SF Markus Elfring
2017-04-18 11:33   ` Yuval Shaia
2017-04-18 11:33     ` Yuval Shaia
2017-04-07 21:07 ` [PATCH 7/9] IB/iser: Add spaces for better code readability SF Markus Elfring
2017-04-07 21:07   ` SF Markus Elfring
2017-04-09  9:02   ` Sagi Grimberg
2017-04-09  9:02     ` Sagi Grimberg
2017-04-07 21:09 ` [PATCH 9/9] IB/isert: Improve size determinations in three functions SF Markus Elfring
2017-04-07 21:09   ` SF Markus Elfring
2017-04-09  9:02   ` Sagi Grimberg
2017-04-09  9:02     ` Sagi Grimberg

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=75e5726b-d75f-1b79-1242-08f6440e1691@users.sourceforge.net \
    --to=elfring-rn4veauk+akrv+lv9mx5uipxlwaovq5f@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dsa-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org \
    --cc=erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=ferasda-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=pabeni-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=roid-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.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.