Skip to contentSkip to conversation

RDMA/rtrs: Fix the problem of variable not initialized fully

PATCH Applied Zhu Yanjun 6 participants 9 messages Sep 19, 2023 – Sep 20, 2023

Subsystems (2)
lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH 1/1 RDMA/rtrs: Fix the problem of variable not initialized fully

From: Zhu Yanjun <[email protected]>

No functionality change. The variable which is not initialized fully will introduce potential risks.

---
 drivers/infiniband/ulp/rtrs/rtrs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs.c +1 -1
index 3696f367ff51..d80edfffd2e4 100644
@@ -255,7 +255,7 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,
 static int create_qp(struct rtrs_con *con, struct ib_pd *pd,
 		     u32 max_send_wr, u32 max_recv_wr, u32 max_sge)
 {
-	struct ib_qp_init_attr init_attr = {NULL};
+	struct ib_qp_init_attr init_attr = {};
 	struct rdma_cm_id *cm_id = con->cm_id;
 	int ret;
 
Signature · 1 line
2.40.1
#1 lore raw
Quoted 4 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

No functionality change. The variable which is not initialized fully will introduce potential risks.

Are you sure about not being initialized?

Thanks

Quoted 22 lines
---
 drivers/infiniband/ulp/rtrs/rtrs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs.c +1 -1
index 3696f367ff51..d80edfffd2e4 100644
@@ -255,7 +255,7 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,
 static int create_qp(struct rtrs_con *con, struct ib_pd *pd,
 		     u32 max_send_wr, u32 max_recv_wr, u32 max_sge)
 {
-	struct ib_qp_init_attr init_attr = {NULL};
+	struct ib_qp_init_attr init_attr = {};
 	struct rdma_cm_id *cm_id = con->cm_id;
 	int ret;
 
Signature · 1 line
2.40.1
#2 lore raw
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

No functionality change. The variable which is not initialized fully will introduce potential risks.

Are you sure about not being initialized?

About this problem, I think we discussed it previously in RDMA maillist.

And at that time, IIRC, you shared a link with me. The link is as below.

https://www.ex-parrot.com/~chris/random/initialise.html

From what we discussed and the above link, I think it is not initialized fully.

Zhu Yanjun

Quoted 24 lines

Thanks

Quoted 21 lines
---
  drivers/infiniband/ulp/rtrs/rtrs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs.c +1 -1
index 3696f367ff51..d80edfffd2e4 100644
@@ -255,7 +255,7 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,
  static int create_qp(struct rtrs_con *con, struct ib_pd *pd,
  		     u32 max_send_wr, u32 max_recv_wr, u32 max_sge)
  {
-	struct ib_qp_init_attr init_attr = {NULL};
+	struct ib_qp_init_attr init_attr = {};
  	struct rdma_cm_id *cm_id = con->cm_id;
  	int ret;
 
Signature · 1 line
2.40.1
#3 lore raw
Quoted 9 lines · Zhu Yanjun
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

No functionality change. The variable which is not initialized fully will introduce potential risks.

Are you sure about not being initialized?

Quoted 8 lines

About this problem, I think we discussed it previously in RDMA maillist.

And at that time, IIRC, you shared a link with me. The link is as below.

https://www.ex-parrot.com/~chris/random/initialise.html

From what we discussed and the above link, I think it is not initialized fully.

I remember that discussion and it was about slightly different thing:
{} vs {0} in Linux kernel.

However I don't think that I sent you that link.
Anyway, let's take this patch as it is harmless.

Thanks

Quoted 27 lines

Zhu Yanjun

Quoted 23 lines

Thanks

Quoted 20 lines
---
  drivers/infiniband/ulp/rtrs/rtrs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs.c +1 -1
index 3696f367ff51..d80edfffd2e4 100644
@@ -255,7 +255,7 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,
  static int create_qp(struct rtrs_con *con, struct ib_pd *pd,
  		     u32 max_send_wr, u32 max_recv_wr, u32 max_sge)
  {
-	struct ib_qp_init_attr init_attr = {NULL};
+	struct ib_qp_init_attr init_attr = {};
  	struct rdma_cm_id *cm_id = con->cm_id;
  	int ret;
Signature · 1 line
2.40.1
#4 lore raw
Quoted 14 lines · Leon Romanovsky
Quoted 13 lines · Zhu Yanjun
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

No functionality change. The variable which is not initialized fully will introduce potential risks.

Are you sure about not being initialized?

About this problem, I think we discussed it previously in RDMA maillist.

And at that time, IIRC, you shared a link with me. The link is as below.

Quoted 7 lines
Quoted 4 lines

https://www.ex-parrot.com/~chris/random/initialise.html

From what we discussed and the above link, I think it is not initialized
fully.

I remember that discussion and it was about slightly different thing:
{} vs {0} in Linux kernel.

Well, in my mind, I thought they are the same. see: https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Initializing-Structure-Members

In current kernel, {NULL/0} is used in so many other places. beside {NULL}, another partial initializing form

struct class {
	int a, b, c, d, e;
} instance = {

.a = x,
.b = y,
};

They are also used everywhere, it's definitely based on the truth instance.{c,d,e} to be "0".

Thanks

Quoted 33 lines

However I don't think that I sent you that link.
Anyway, let's take this patch as it is harmless.

Thanks

Quoted 27 lines

Zhu Yanjun

Quoted 23 lines

Thanks

Quoted 20 lines
---
   drivers/infiniband/ulp/rtrs/rtrs.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs.c +1 -1
index 3696f367ff51..d80edfffd2e4 100644
@@ -255,7 +255,7 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,
   static int create_qp(struct rtrs_con *con, struct ib_pd *pd,
   		     u32 max_send_wr, u32 max_recv_wr, u32 max_sge)
   {
-	struct ib_qp_init_attr init_attr = {NULL};
+	struct ib_qp_init_attr init_attr = {};
   	struct rdma_cm_id *cm_id = con->cm_id;
   	int ret;
Signature · 1 line
2.40.1
maintainer
#5 lore raw
Quoted 30 lines · Zhijian Li (Fujitsu)
Quoted 14 lines · Leon Romanovsky
Quoted 13 lines · Zhu Yanjun
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

No functionality change. The variable which is not initialized fully will introduce potential risks.

Are you sure about not being initialized?

About this problem, I think we discussed it previously in RDMA maillist.

And at that time, IIRC, you shared a link with me. The link is as below.

Quoted 7 lines
Quoted 4 lines

https://www.ex-parrot.com/~chris/random/initialise.html

From what we discussed and the above link, I think it is not initialized
fully.

I remember that discussion and it was about slightly different thing:
{} vs {0} in Linux kernel.

Well, in my mind, I thought they are the same. see: https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Initializing-Structure-Members

In current kernel, {NULL/0} is used in so many other places. beside {NULL}, another partial initializing form

Quoted 8 lines
struct class {
        int a, b, c, d, e;
} instance = {

.a = x,
.b = y,
};

They are also used everywhere, it's definitely based on the truth instance.{c,d,e} to be "0".

I also think they are the same. oth it is harmless.

Thx

Quoted 39 lines

Thanks

Quoted 33 lines

However I don't think that I sent you that link.
Anyway, let's take this patch as it is harmless.

Thanks

Quoted 27 lines

Zhu Yanjun

Quoted 23 lines

Thanks

Quoted 20 lines
---
   drivers/infiniband/ulp/rtrs/rtrs.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs.c +1 -2
index 3696f367ff51..d80edfffd2e4 100644
@@ -255,7 +255,7 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,
   static int create_qp(struct rtrs_con *con, struct ib_pd *pd,
                        u32 max_send_wr, u32 max_recv_wr, u32 max_sge)
   {
-  struct ib_qp_init_attr init_attr = {NULL};
+  struct ib_qp_init_attr init_attr = {};
           struct rdma_cm_id *cm_id = con->cm_id;
           int ret;
--

2.40.1

#6 lore raw
In reply to Zhijian Li (Fujitsu)
Quoted 19 lines · Zhijian Li (Fujitsu)
Quoted 16 lines · Leon Romanovsky
Quoted 15 lines · Zhu Yanjun
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

No functionality change. The variable which is not initialized fully will introduce potential risks.

Are you sure about not being initialized?

About this problem, I think we discussed it previously in RDMA maillist.

And at that time, IIRC, you shared a link with me. The link is as below.

https://www.ex-parrot.com/~chris/random/initialise.html

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

From what we discussed and the above link, I think it is not initialized
fully.

I remember that discussion and it was about slightly different thing:
{} vs {0} in Linux kernel.

Well, in my mind, I thought they are the same. see: https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Initializing-Structure-Members

It is GCC specific implementation, the original discussion was about C-standard.

Thanks

#7 lore raw
Quoted 9 lines · Leon Romanovsky
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

About this problem, I think we discussed it previously in RDMA maillist.

And at that time, IIRC, you shared a link with me. The link is as below.

https://www.ex-parrot.com/~chris/random/initialise.html

From what we discussed and the above link, I think it is not initialized
fully.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I remember that discussion and it was about slightly different thing:
{} vs {0} in Linux kernel.

Well, in my mind, I thought they are the same. see: https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Initializing-Structure-Members

It is GCC specific implementation, the original discussion was about C-standard.

Yes, the C standard says they are different constructs and pedantically only {} is required to fully zero the struct, padding and all.

{0} says 'zero initialize the first member of the struct', it is a terrible construct because the first member may not be an integer, don't use it.

Jason