fpga: zynqmp-fpga: Correctly handle error pointer
Subsystems (2)
Moritz Fischer
maintainerPATCH v2 1/1 fpga: zynqmp-fpga: Correctly handle error pointer
Fixes the following static checker errors:
drivers/fpga/zynqmp-fpga.c:50 zynqmp_fpga_ops_write()
error: 'eemi_ops' dereferencing possible ERR_PTR()
drivers/fpga/zynqmp-fpga.c:84 zynqmp_fpga_ops_state()
error: 'eemi_ops' dereferencing possible ERR_PTR()
Note: This does not handle the EPROBE_DEFER value in a
special manner.
Fixes commit c09f7471127e ("fpga manager: Adding FPGA Manager support for Xilinx zynqmp")
---
Changes from v1:
- Address Alan's feedback regarding handling both occurences.
--- drivers/fpga/zynqmp-fpga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/zynqmp-fpga.c +2 -2
@@ -47,7 +47,7 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,char *kbuf;int ret; -if (!eemi_ops || !eemi_ops->fpga_load) +if (IS_ERR_OR_NULL (eemi_ops) || !eemi_ops->fpga_load)return -ENXIO ; priv = mgr->priv;
@@ -81,7 +81,7 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)const struct zynqmp_eemi_ops *eemi_ops =zynqmp_pm_get_eemi_ops ();u32 status; -if (!eemi_ops || !eemi_ops->fpga_get_status) +if (IS_ERR_OR_NULL (eemi_ops) || !eemi_ops->fpga_get_status)return FPGA_MGR_STATE_UNKNOWN ; eemi_ops->fpga_get_status (&status);
Signature · 1 line
2.21.0
Quoted 9 lines · Moritz Fischer
Fixes the following static checker errors:
drivers/fpga/zynqmp-fpga.c:50zynqmp_fpga_ops_write()
error: 'eemi_ops' dereferencing possibleERR_PTR()
drivers/fpga/zynqmp-fpga.c:84zynqmp_fpga_ops_state()
error: 'eemi_ops' dereferencing possibleERR_PTR()
Quoted 7 lines
Note: This does not handle the
EPROBE_DEFERvalue in a
special manner.Fixes commit
c09f7471127e("fpga manager: Adding FPGA Manager support for Xilinx zynqmp")Reported-by Dan Carpenter <[email protected]>Signed-off-by Moritz Fischer <[email protected]>
Thanks!
Alan
Quoted 34 lines
---
Changes from v1:
- Address Alan's feedback regarding handling both occurences.--- drivers/fpga/zynqmp-fpga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/fpga/zynqmp-fpga.c +2
-3@@ -47,7 +47,7 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,char *kbuf;int ret; -if (!eemi_ops || !eemi_ops->fpga_load) +if (IS_ERR_OR_NULL (eemi_ops) || !eemi_ops->fpga_load)return -ENXIO ; priv = mgr->priv;@@ -81,7 +81,7 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)const struct zynqmp_eemi_ops *eemi_ops =zynqmp_pm_get_eemi_ops ();u32 status; -if (!eemi_ops || !eemi_ops->fpga_get_status) +if (IS_ERR_OR_NULL (eemi_ops) || !eemi_ops->fpga_get_status)return FPGA_MGR_STATE_UNKNOWN ; eemi_ops->fpga_get_status (&status); --2.21.0