fpga: stratix10-soc: fix NULL vs IS_ERR() checking
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
@@ -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
Tom Rix
reviewerQuoted 13 lines · Miaoqian Lin
The
stratix10_svc_allocate_memoryfunction does not return NULL. It returnsERR_PTR(-ENOMEM). UseIS_ERRcheck the return value.Signed-off-by Miaoqian Lin <[email protected]>--- drivers/fpga/stratix10-soc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/stratix10-soc.c +0
-0
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
-0goto init_done;
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
@@ -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
Quoted 13 lines · Miaoqian Lin
The
stratix10_svc_allocate_memoryfunction does not return NULL. It returnsERR_PTR(-ENOMEM). UseIS_ERRcheck the return value.Signed-off-by Miaoqian Lin <[email protected]>--- drivers/fpga/stratix10-soc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/fpga/stratix10-soc.c +0
-0
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
-0goto init_done; }
Quoted 26 lines · Tom Rix
Quoted 13 lines · Miaoqian Lin
The
stratix10_svc_allocate_memoryfunction does not return NULL. It returnsERR_PTR(-ENOMEM). UseIS_ERRcheck the return value.Signed-off-by Miaoqian Lin <[email protected]>--- drivers/fpga/stratix10-soc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/fpga/stratix10-soc.c +0
-0drivers/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
Reviewed-by Tom Rix <[email protected]>
Thanks,
Yilun
Quoted 3 lines
Quoted 3 lines
drivers/fpga/stratix10-soc.c +0
-0goto init_done; }
Wu, Hao
Acked-byQuoted 4 lines
Quoted 4 lines · Miaoqian Lin
Quoted 3 lines
The
stratix10_svc_allocate_memoryfunction does not return NULL. It returnsERR_PTR(-ENOMEM). UseIS_ERRcheck 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
Signed-off-by Miaoqian Lin <[email protected]>--- drivers/fpga/stratix10-soc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/fpga/stratix10-soc.c +0
-0@@ -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!
Reviewed-by Tom Rix <[email protected]>Acked-by Xu Yilun <[email protected]>Thanks,
YilunQuoted 3 lines
Quoted 3 lines
drivers/fpga/stratix10-soc.c +0
-0goto init_done; }
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.
--- drivers/fpga/stratix10-soc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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); goto init_done; }
Signature · 1 line
2.17.1