Skip to contentSkip to conversation

powerpc/fsl_rio: fix a missing error code

PATCH Applied Dan Carpenter 2 participants 3 messages Aug 4, 2016 – Aug 5, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/fsl_rio: fix a missing error code

We should set the error code here. Otherwise static checkers complain.

arch/powerpc/sysdev/fsl_rio.c +1 -0
index 984e816..68e7c0d 100644
@@ -491,6 +491,7 @@ int fsl_rio_setup(struct platform_device *dev)
 	rmu_node = of_parse_phandle(dev->dev.of_node, "fsl,srio-rmu-handle", 0);
 	if (!rmu_node) {
 		dev_err(&dev->dev, "No valid fsl,srio-rmu-handle property\n");
+		rc = -ENOENT;
 		goto err_rmu;
 	}
 	rc = of_address_to_resource(rmu_node, 0, &rmu_regs);
#1 lore raw
Quoted 2 lines · On Thu, 4 Aug 2016 08:35:25 +0300 Dan Carpenter <[email protected]>…

We should set the error code here. Otherwise static checkers complain.

hm.

arch/powerpc/sysdev/fsl_rio.c int fsl_rio_setup(struct platform_device *dev) · line 497

Quoted 10 lines
arch/powerpc/sysdev/fsl_rio.c +1 -0
@@ -491,6 +491,7 @@ int fsl_rio_setup(struct platform_device *dev)
 	rmu_node = of_parse_phandle(dev->dev.of_node, "fsl,srio-rmu-handle", 0);
 	if (!rmu_node) {
 		dev_err(&dev->dev, "No valid fsl,srio-rmu-handle property\n");
+		rc = -ENOENT;
 		goto err_rmu;
 	}
 	rc = of_address_to_resource(rmu_node, 0, &rmu_regs);

afaict the function will return 0 in this case, which is a flat out bug. But why do static checkers complain? The code will return a suitably initialized value?

IOW, please always quote the checker/compiler output when fixing a bug!

#2 lore raw
Quoted 22 lines · Andrew Morton
Quoted 2 lines · On Thu, 4 Aug 2016 08:35:25 +0300 Dan Carpenter <[email protected]>…

We should set the error code here. Otherwise static checkers complain.

hm.

arch/powerpc/sysdev/fsl_rio.c int fsl_rio_setup(struct platform_device *dev) · line 497

Quoted 10 lines
arch/powerpc/sysdev/fsl_rio.c +1 -0
@@ -491,6 +491,7 @@ int fsl_rio_setup(struct platform_device *dev)
 	rmu_node = of_parse_phandle(dev->dev.of_node, "fsl,srio-rmu-handle", 0);
 	if (!rmu_node) {
 		dev_err(&dev->dev, "No valid fsl,srio-rmu-handle property\n");
+		rc = -ENOENT;
 		goto err_rmu;
 	}
 	rc = of_address_to_resource(rmu_node, 0, &rmu_regs);

afaict the function will return 0 in this case, which is a flat out bug. But why do static checkers complain? The code will return a suitably initialized value?

Quoted 1 line

IOW, please always quote the checker/compiler output when fixing a bug!

Coccinelle has a check for missing error codes and I'm working on one for Smatch as well.

regards,
dan carpenter