Skip to contentSkip to conversation

fpga: stratix10-soc: fix NULL vs IS_ERR() checking

PATCH Superseded Miaoqian Lin 4 participants 7 messages Dec 11, 2021 – Dec 13, 2021 FPGA manager framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga: stratix10-soc: fix NULL vs IS_ERR() checking

The stratix10_svc_allocate_memory function does not return NULL. It returns ERR_PTR(-ENOMEM). Use IS_ERR check the return value.

---
 drivers/fpga/stratix10-soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/stratix10-soc.c +1 -1
index 047fd7f23706..2d2687a90ae6 100644
@@ -213,7 +213,7 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
 	/* Allocate buffers from the service layer's pool. */
 	for (i = 0; i < NUM_SVC_BUFS; i++) {
 		kbuf = stratix10_svc_allocate_memory(priv->chan, SVC_BUF_SIZE);
-		if (!kbuf) {
+		if (IS_ERR(kbuf)) {
 			s10_free_buffers(mgr);
 			ret = -ENOMEM;
 			goto init_done;
Signature · 1 line
2.17.1
reviewer
#1 lore raw
Quoted 13 lines · Miaoqian Lin

The stratix10_svc_allocate_memory function does not return NULL. It returns ERR_PTR(-ENOMEM). Use IS_ERR check the return value.

---
  drivers/fpga/stratix10-soc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/stratix10-soc.c +0 -0
index 047fd7f23706..2d2687a90ae6 100644

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 218

Quoted 7 lines
drivers/fpga/stratix10-soc.c +1 -1
@@ -213,7 +213,7 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
  	/* Allocate buffers from the service layer's pool. */
  	for (i = 0; i < NUM_SVC_BUFS; i++) {
  		kbuf = stratix10_svc_allocate_memory(priv->chan, SVC_BUF_SIZE);
-		if (!kbuf) {
+		if (IS_ERR(kbuf)) {
  			s10_free_buffers(mgr);
  			ret = -ENOMEM;

This should also change to

ret = PTR_ERR(kbuf)

Tom

Quoted 1 line
drivers/fpga/stratix10-soc.c +0 -0
  			goto init_done;
#2 lore raw

PATCH v2 1/1 fpga: stratix10-soc: fix NULL vs IS_ERR() checking

The stratix10_svc_allocate_memory function does not return NULL. It returns ERR_PTR(-ENOMEM). Use IS_ERR check the return value.

---
 drivers/fpga/stratix10-soc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/stratix10-soc.c +2 -2
index 047fd7f23706..91212bab5871 100644
@@ -213,9 +213,9 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
 	/* Allocate buffers from the service layer's pool. */
 	for (i = 0; i < NUM_SVC_BUFS; i++) {
 		kbuf = stratix10_svc_allocate_memory(priv->chan, SVC_BUF_SIZE);
-		if (!kbuf) {
+		if (IS_ERR(kbuf)) {
 			s10_free_buffers(mgr);
-			ret = -ENOMEM;
+			ret = PTR_ERR(kbuf);
 			goto init_done;
 		}
 
Signature · 1 line
2.17.1
reviewer Reviewed-by on v2 1/1
#3 lore raw
Quoted 13 lines · Miaoqian Lin

The stratix10_svc_allocate_memory function does not return NULL. It returns ERR_PTR(-ENOMEM). Use IS_ERR check the return value.

---
  drivers/fpga/stratix10-soc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/stratix10-soc.c +0 -0
index 047fd7f23706..91212bab5871 100644

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 218

Quoted 8 lines
drivers/fpga/stratix10-soc.c +2 -2
@@ -213,9 +213,9 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
  	/* Allocate buffers from the service layer's pool. */
  	for (i = 0; i < NUM_SVC_BUFS; i++) {
  		kbuf = stratix10_svc_allocate_memory(priv->chan, SVC_BUF_SIZE);
-		if (!kbuf) {
+		if (IS_ERR(kbuf)) {
  			s10_free_buffers(mgr);
-			ret = -ENOMEM;
+			ret = PTR_ERR(kbuf);

Thanks!

Quoted 3 lines
drivers/fpga/stratix10-soc.c +0 -0
  			goto init_done;
  		}
 
maintainer Acked-by
#4 lore raw
Quoted 26 lines · Tom Rix
Quoted 13 lines · Miaoqian Lin

The stratix10_svc_allocate_memory function does not return NULL. It returns ERR_PTR(-ENOMEM). Use IS_ERR check the return value.

---
  drivers/fpga/stratix10-soc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/stratix10-soc.c +0 -0
index 047fd7f23706..91212bab5871 100644

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 218

Quoted 8 lines
drivers/fpga/stratix10-soc.c +2 -2
@@ -213,9 +213,9 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
  	/* Allocate buffers from the service layer's pool. */
  	for (i = 0; i < NUM_SVC_BUFS; i++) {
  		kbuf = stratix10_svc_allocate_memory(priv->chan, SVC_BUF_SIZE);
-		if (!kbuf) {
+		if (IS_ERR(kbuf)) {
  			s10_free_buffers(mgr);
-			ret = -ENOMEM;
+			ret = PTR_ERR(kbuf);

Thanks!

Quoted 1 line

Thanks,
Yilun

Quoted 3 lines
Quoted 3 lines
drivers/fpga/stratix10-soc.c +0 -0
  			goto init_done;
  		}
Acked-by
#5 lore raw
Quoted 4 lines
Quoted 4 lines · Miaoqian Lin
Quoted 3 lines

The stratix10_svc_allocate_memory function does not return NULL. It returns ERR_PTR(-ENOMEM). Use IS_ERR check the return value.

Please add "Fixes" tag, then

Thanks for the patch.
Hao

Quoted 33 lines
Quoted 10 lines

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager

Quoted 10 lines
---
  drivers/fpga/stratix10-soc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/stratix10-soc.c +0 -0
index 047fd7f23706..91212bab5871 100644
@@ -213,9 +213,9 @@ static int s10_ops_write_init(struct fpga_manager

*mgr,

Quoted 3 lines

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr,

Quoted 3 lines
drivers/fpga/stratix10-soc.c +0 -0
  	/* Allocate buffers from the service layer's pool. */
  	for (i = 0; i < NUM_SVC_BUFS; i++) {
  		kbuf = stratix10_svc_allocate_memory(priv->chan,

SVC_BUF_SIZE);

Quoted 9 lines

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 218

Quoted 5 lines
drivers/fpga/stratix10-soc.c +2 -2
-		if (!kbuf) {
+		if (IS_ERR(kbuf)) {
  			s10_free_buffers(mgr);
-			ret = -ENOMEM;
+			ret = PTR_ERR(kbuf);

Thanks!

Thanks,
Yilun

Quoted 3 lines
Quoted 3 lines
drivers/fpga/stratix10-soc.c +0 -0
  			goto init_done;
  		}
#6 lore raw

PATCH v3 1/1 fpga: stratix10-soc: fix NULL vs IS_ERR() checking

The stratix10_svc_allocate_memory function does not return NULL. It returns ERR_PTR(-ENOMEM). Use IS_ERR check the return value.

Fixes e7eef1d7633a("fpga: add intel stratix10 soc fpga manager driver")
---
 drivers/fpga/stratix10-soc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/stratix10-soc.c +2 -2
index 047fd7f23706..91212bab5871 100644
@@ -213,9 +213,9 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
 	/* Allocate buffers from the service layer's pool. */
 	for (i = 0; i < NUM_SVC_BUFS; i++) {
 		kbuf = stratix10_svc_allocate_memory(priv->chan, SVC_BUF_SIZE);
-		if (!kbuf) {
+		if (IS_ERR(kbuf)) {
 			s10_free_buffers(mgr);
-			ret = -ENOMEM;
+			ret = PTR_ERR(kbuf);
 			goto init_done;
 		}
 
Signature · 1 line
2.17.1