Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1583970 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-02-18 21:50 +0100 |
| Last post | 2017-02-18 22:50 +0100 |
| Articles | 9 on this page of 49 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 00/29] IB/mlx: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 21:50 +0100
[PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:20 +0100
[PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 06/29] IB/mlx4: Delete three unnecessary return statements SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 06/29] IB/mlx4: Delete three unnecessary return statements Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 05/29] IB/mlx4: Fix a typo in a comment line SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 05/29] IB/mlx4: Fix a typo in a comment line Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 23:40 +0100
[PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 13/29] IB/mlx4: Split a condition check in five functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 13/29] IB/mlx4: Split a condition check in five functions Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 18/29] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
[PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 20:50 +0100
[PATCH 14/29] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
[PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:40 +0100
Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:40 +0100
[PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 21:00 +0100
[PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 20:50 +0100
[PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 21:10 +0100
[PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 24/29] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 28/29] IB/mlx5: Less function calls in create_kernel_qp() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 21:00 +0100
[PATCH 16/29] IB/mlx4: Improve another size determination in do_slave_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:30 +0100
Re: [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:20 +0100
[PATCH 26/29] IB/mlx4: Enclose 14 expressions for the sizeof operator by parentheses SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:30 +0100
[PATCH 25/29] IB/mlx4: Add spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:50 +0100
Page 3 of 3 — ← Prev page 1 2 [3]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 28/29] IB/mlx5: Less function calls in create_kernel_qp() after error detection |
| Message-ID | <tckAa-73M-15@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:00:50 +0100
The kfree() function was called in up to five cases
by the create_kernel_qp() function during error handling
even if the passed data structure member contained a null pointer.
* Adjust jump targets according to the Linux coding style convention.
* Split a condition check for memory allocation failures so that
each pointer from these function calls will be checked immediately.
See also background information:
Topic "CWE-754: Improper check for unusual or exceptional conditions"
Link: https://cwe.mitre.org/data/definitions/754.html
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx5/qp.c | 43 ++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index e6e9b468b206..c47afce5fc6a 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -930,7 +930,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
*in = mlx5_vzalloc(*inlen);
if (!*in) {
err = -ENOMEM;
- goto err_buf;
+ goto free_buffer;
}
qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
@@ -952,45 +952,56 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
err = mlx5_db_alloc(dev->mdev, &qp->db);
if (err) {
mlx5_ib_dbg(dev, "err %d\n", err);
- goto err_free;
+ goto vfree_in;
}
qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
sizeof(*qp->sq.wrid),
GFP_KERNEL);
+ if (!qp->sq.wrid)
+ goto free_db;
+
qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
sizeof(*qp->sq.wr_data),
GFP_KERNEL);
+ if (!qp->sq.wr_data)
+ goto free_sq_wrid;
+
qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
sizeof(*qp->rq.wrid),
GFP_KERNEL);
+ if (!qp->rq.wrid)
+ goto free_sq_wr_data;
+
qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
sizeof(*qp->sq.w_list),
GFP_KERNEL);
+ if (!qp->sq.w_list)
+ goto free_rq_wrid;
+
qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
sizeof(*qp->sq.wqe_head),
GFP_KERNEL);
- if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
- !qp->sq.w_list || !qp->sq.wqe_head) {
- err = -ENOMEM;
- goto err_wrid;
- }
+ if (!qp->sq.wqe_head)
+ goto free_sq_w_list;
+
qp->create_type = MLX5_QP_KERNEL;
return 0;
-
-err_wrid:
- kfree(qp->sq.wqe_head);
+free_sq_w_list:
kfree(qp->sq.w_list);
- kfree(qp->sq.wrid);
- kfree(qp->sq.wr_data);
+free_rq_wrid:
kfree(qp->rq.wrid);
+free_sq_wr_data:
+ kfree(qp->sq.wr_data);
+free_sq_wrid:
+ kfree(qp->sq.wrid);
+free_db:
mlx5_db_free(dev->mdev, &qp->db);
-
-err_free:
+ err = -ENOMEM;
+vfree_in:
kvfree(*in);
-
-err_buf:
+free_buffer:
mlx5_buf_free(dev->mdev, &qp->buf);
return err;
}
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp() |
| Message-ID | <tckAa-73M-17@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 20:12:44 +0100
Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx5/qp.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 5ed5208d0ddd..e6e9b468b206 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -955,12 +955,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
goto err_free;
}
- qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
- qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
- qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
- qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
- qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
-
+ qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
+ sizeof(*qp->sq.wrid),
+ GFP_KERNEL);
+ qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
+ sizeof(*qp->sq.wr_data),
+ GFP_KERNEL);
+ qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
+ sizeof(*qp->rq.wrid),
+ GFP_KERNEL);
+ qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
+ sizeof(*qp->sq.w_list),
+ GFP_KERNEL);
+ qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
+ sizeof(*qp->sq.wqe_head),
+ GFP_KERNEL);
if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
!qp->sq.w_list || !qp->sq.wqe_head) {
err = -ENOMEM;
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common() |
| Message-ID | <tckAa-73M-21@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:29:30 +0100
Replace the specification of two data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determinations a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/qp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 11fec4a8fae5..cc7bd257a1fd 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
(qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
- sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
+ sqp = kzalloc(sizeof(*sqp), gfp);
if (!sqp)
return -ENOMEM;
qp = &sqp->qp;
qp->pri.vid = 0xFFFF;
qp->alt.vid = 0xFFFF;
} else {
- qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
+ qp = kzalloc(sizeof(*qp), gfp);
if (!qp)
return -ENOMEM;
qp->pri.vid = 0xFFFF;
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 21:00 +0100 |
| Subject | Re: [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common() |
| Message-ID | <tcFOh-35c-15@gated-at.bofh.it> |
| In reply to | #1583999 |
> On Feb 18, 2017, at 11:15 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 18:29:30 +0100
>
> Replace the specification of two data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determinations a bit safer according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 11fec4a8fae5..cc7bd257a1fd 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
> if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
> (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
> MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
> - sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
> + sqp = kzalloc(sizeof(*sqp), gfp);
> if (!sqp)
> return -ENOMEM;
> qp = &sqp->qp;
> qp->pri.vid = 0xFFFF;
> qp->alt.vid = 0xFFFF;
> } else {
> - qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
> + qp = kzalloc(sizeof(*qp), gfp);
> if (!qp)
> return -ENOMEM;
> qp->pri.vid = 0xFFFF;
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 16/29] IB/mlx4: Improve another size determination in do_slave_init() |
| Message-ID | <tckAa-73M-19@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:25:19 +0100
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" 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/hw/mlx4/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b2b472977a39..b78f17623121 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3106,7 +3106,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
return;
for (i = 0; i < ports; i++) {
- dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
+ dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC);
if (!dm[i]) {
while (--i >= 0)
kfree(dm[i]);
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:30 +0100 |
| Subject | [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() |
| Message-ID | <tckJP-76Y-1@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 22:06:24 +0100
The script "checkpatch.pl" pointed information out like the following.
WARNING: kfree(NULL) is safe and this check is probably not required
Thus fix the affected source code place.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/mad.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 75b6522b3a8f..9518b7244269 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1966,10 +1966,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
{
- if (dev->sriov.demux[port - 1].tun[slave]) {
- kfree(dev->sriov.demux[port - 1].tun[slave]);
- dev->sriov.demux[port - 1].tun[slave] = NULL;
- }
+ kfree(dev->sriov.demux[port - 1].tun[slave]);
+ dev->sriov.demux[port - 1].tun[slave] = NULL;
}
static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 18:20 +0100 |
| Subject | Re: [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() |
| Message-ID | <tcDjr-1Gc-3@gated-at.bofh.it> |
| In reply to | #1584001 |
> On Feb 18, 2017, at 11:28 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 22:06:24 +0100
>
> The script "checkpatch.pl" pointed information out like the following.
>
> WARNING: kfree(NULL) is safe and this check is probably not required
>
> Thus fix the affected source code place.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 75b6522b3a8f..9518b7244269 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1966,10 +1966,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
>
> static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
> {
> - if (dev->sriov.demux[port - 1].tun[slave]) {
> - kfree(dev->sriov.demux[port - 1].tun[slave]);
> - dev->sriov.demux[port - 1].tun[slave] = NULL;
> - }
> + kfree(dev->sriov.demux[port - 1].tun[slave]);
> + dev->sriov.demux[port - 1].tun[slave] = NULL;
> }
In case it was NULL, we will have a redundant assignment here.
I don't think this change is needed..
>
> static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:30 +0100 |
| Subject | [PATCH 26/29] IB/mlx4: Enclose 14 expressions for the sizeof operator by parentheses |
| Message-ID | <tckJQ-76Y-7@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 19:30:41 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script "checkpatch.pl" pointed information out like the following.
WARNING: sizeof … should be sizeof(…)
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/qp.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 16164ff09a86..3ffba8ebba7f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -247,9 +247,10 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
s = sizeof(struct mlx4_wqe_ctrl_seg);
if (qp->ibqp.qp_type == IB_QPT_UD) {
- struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof *ctrl;
+ struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof(*ctrl);
struct mlx4_av *av = (struct mlx4_av *)dgram->av;
- memset(dgram, 0, sizeof *dgram);
+
+ memset(dgram, 0, sizeof(*dgram));
av->port_pd = cpu_to_be32((qp->port << 24) | to_mpd(qp->ibqp.pd)->pdn);
s += sizeof(struct mlx4_wqe_datagram_seg);
}
@@ -257,7 +258,8 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
/* Pad the remainder of the WQE with an inline data segment. */
if (size > s) {
inl = wqe + s;
- inl->byte_count = cpu_to_be32(1 << 31 | (size - s - sizeof *inl));
+ inl->byte_count = cpu_to_be32(1 << 31
+ | (size - s - sizeof(*inl)));
}
ctrl->srcrb_flags = 0;
ctrl->qpn_vlan.fence_size = size / 16;
@@ -727,7 +729,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
if (pd->uobject) {
struct mlx4_ib_create_qp ucmd;
- if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+ if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
err = -EFAULT;
goto err;
}
@@ -1180,7 +1182,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
case IB_QPT_RC:
case IB_QPT_UC:
case IB_QPT_RAW_PACKET:
- qp = kzalloc(sizeof *qp, gfp);
+ qp = kzalloc(sizeof(*qp), gfp);
if (!qp)
return ERR_PTR(-ENOMEM);
qp->pri.vid = 0xFFFF;
@@ -1635,7 +1637,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
IB_LINK_LAYER_ETHERNET)
return -ENOTSUPP;
- context = kzalloc(sizeof *context, GFP_KERNEL);
+ context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context)
return -ENOMEM;
@@ -2299,7 +2301,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
struct mlx4_ib_dev *mdev = to_mdev(sqp->qp.ibqp.device);
struct ib_device *ib_dev = &mdev->ib_dev;
struct mlx4_wqe_mlx_seg *mlx = wqe;
- struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+ struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
struct mlx4_ib_ah *ah = to_mah(wr->ah);
u16 pkey;
u32 qkey;
@@ -2428,7 +2430,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
struct ib_device *ib_dev = sqp->qp.ibqp.device;
struct mlx4_wqe_mlx_seg *mlx = wqe;
struct mlx4_wqe_ctrl_seg *ctrl = wqe;
- struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+ struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
struct mlx4_ib_ah *ah = to_mah(wr->ah);
union ib_gid sgid;
u16 pkey;
@@ -2809,7 +2811,7 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
int spc;
int i;
- memcpy(&hdr.av, &ah->av, sizeof hdr.av);
+ memcpy(&hdr.av, &ah->av, sizeof(hdr.av));
hdr.remote_qpn = cpu_to_be32(wr->remote_qpn);
hdr.pkey_index = cpu_to_be16(wr->pkey_index);
hdr.qkey = cpu_to_be32(wr->remote_qkey);
@@ -2888,7 +2890,7 @@ static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
__be32 *lso_hdr_sz, __be32 *blh)
{
- unsigned halign = ALIGN(sizeof *wqe + wr->hlen, 16);
+ unsigned int halign = ALIGN(sizeof(*wqe) + wr->hlen, 16);
if (unlikely(halign > MLX4_IB_CACHE_LINE_SIZE))
*blh = cpu_to_be32(1 << 6);
@@ -3010,9 +3012,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
qp->sq_signal_bits;
ctrl->imm = send_ieth(wr);
-
- wqe += sizeof *ctrl;
- size = sizeof *ctrl / 16;
+ wqe += sizeof(*ctrl);
+ size = sizeof(*ctrl) / 16;
switch (qp->mlx4_ib_qp_type) {
case MLX4_IB_QPT_RC:
@@ -3390,7 +3391,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
struct mlx4_dev *dev = ibdev->dev;
int is_eth;
- memset(ib_ah_attr, 0, sizeof *ib_ah_attr);
+ memset(ib_ah_attr, 0, sizeof(*ib_ah_attr));
ib_ah_attr->port_num = path->sched_queue & 0x40 ? 2 : 1;
if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
@@ -3416,7 +3417,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
ib_ah_attr->grh.flow_label =
be32_to_cpu(path->tclass_flowlabel) & 0xfffff;
memcpy(ib_ah_attr->grh.dgid.raw,
- path->rgid, sizeof ib_ah_attr->grh.dgid.raw);
+ path->rgid, sizeof(ib_ah_attr->grh.dgid.raw));
}
}
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:50 +0100 |
| Subject | [PATCH 25/29] IB/mlx4: Add spaces for better code readability |
| Message-ID | <tcl3c-7dG-7@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:52:11 +0100
Use space characters at some source code places according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/qp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 47a647c1d94f..16164ff09a86 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1063,7 +1063,7 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
list_del(&qp->cq_recv_list);
if (!is_user) {
__mlx4_ib_cq_clean(recv_cq, qp->mqp.qpn,
- qp->ibqp.srq ? to_msrq(qp->ibqp.srq): NULL);
+ qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
if (send_cq != recv_cq)
__mlx4_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
}
@@ -2585,7 +2585,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
u16 ether_type;
u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
- ether_type = (!is_udp) ? ETH_P_IBOE:
+ ether_type = (!is_udp) ? ETH_P_IBOE :
(ip_version == 4 ? ETH_P_IP : ETH_P_IPV6);
mlx->sched_prio = cpu_to_be16(pcp);
--
2.11.1
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | linux.kernel
csiph-web