Skip to contentSkip to conversation

fpga: zynqmp-fpga: Correctly handle error pointer

PATCH Superseded Moritz Fischer 2 participants 3 messages May 7, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Moritz Fischer

author maintainer
#0 lore raw

PATCH 1/1 fpga: zynqmp-fpga: Correctly handle error pointer

Fixes the following static checker error:

drivers/fpga/zynqmp-fpga.c:50 zynqmp_fpga_ops_write()
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")

---
 drivers/fpga/zynqmp-fpga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/zynqmp-fpga.c +1 -1
index f7cbaadf49ab..abcb0b2e75bf 100644
@@ -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;
Signature · 1 line
2.21.0
#1 lore raw

On Tue, May 7, 2019 at 12:03 PM Moritz Fischer <[email protected]> wrote:

Hi Moritz,

Quoted 22 lines

Fixes the following static checker error:

drivers/fpga/zynqmp-fpga.c:50 zynqmp_fpga_ops_write()
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")

---
 drivers/fpga/zynqmp-fpga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/zynqmp-fpga.c +0 -0
index f7cbaadf49ab..abcb0b2e75bf 100644

drivers/fpga/zynqmp-fpga.c static int zynqmp_fpga_ops_write(struct fpga_manager *mgr, · line 50

Quoted 5 lines
drivers/fpga/zynqmp-fpga.c +1 -1
@@ -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)

This if statement also happens in fpga_mgr_states zynqmp_fpga_ops_state(), so we'll need this fix there also.

Quoted 6 lines
drivers/fpga/zynqmp-fpga.c +0 -1
                return -ENXIO;
 
        priv = mgr->priv;
--

2.21.0

Alan

author maintainer
#2 lore raw

Alan,

Quoted 29 lines · Alan Tull

On Tue, May 7, 2019 at 12:03 PM Moritz Fischer <[email protected]> wrote:

Hi Moritz,

Quoted 25 lines

Fixes the following static checker error:

drivers/fpga/zynqmp-fpga.c:50 zynqmp_fpga_ops_write()
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")

---
 drivers/fpga/zynqmp-fpga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/zynqmp-fpga.c +0 -0
index f7cbaadf49ab..abcb0b2e75bf 100644
@@ -47,7 +47,7 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
        char *kbuf;
        int ret;
 
Quoted 5 lines

drivers/fpga/zynqmp-fpga.c static int zynqmp_fpga_ops_write(struct fpga_manager *mgr, · line 50

Quoted 2 lines
drivers/fpga/zynqmp-fpga.c +1 -1
-       if (!eemi_ops || !eemi_ops->fpga_load)
+       if (IS_ERR_OR_NULL(eemi_ops) || !eemi_ops->fpga_load)

This if statement also happens in fpga_mgr_states zynqmp_fpga_ops_state(), so we'll need this fix there also.

Good catch, will fix in v2.

Thanks
Moritz