char: xilinx_hwicap: missing error code if ioremap() fails
Subsystems (3)
PATCH 1/1 char: xilinx_hwicap: missing error code if ioremap() fails
Return -ENOMEM instead of success if ioremap() fails.
---
Static checker stuff, I can't compile this.
drivers/char/xilinx_hwicap/xilinx_hwicap.c +1 -0
@@ -661,6 +661,7 @@ static int hwicap_setup(struct device *dev, int id, drvdata->base_address =ioremap (drvdata->mem_start, drvdata->mem_size);if (!drvdata->base_address) {dev_err (dev,"ioremap() failed\n" ); + retval = -ENOMEM ; goto failed2; }
Quoted 4 lines · Dan Carpenter
Return
-ENOMEMinstead of success ifioremap()fails.Signed-off-by Dan Carpenter <[email protected]>
Best regards,
Jingoo Han
Quoted 15 lines
---
Static checker stuff, I can't compile this.drivers/char/xilinx_hwicap/xilinx_hwicap.c +1
-0@@ -661,6 +661,7 @@ static int hwicap_setup(struct device *dev, int id, drvdata->base_address =ioremap (drvdata->mem_start, drvdata->mem_size);if (!drvdata->base_address) {dev_err (dev,"ioremap() failed\n" ); + retval = -ENOMEM ; goto failed2; }
Quoted 14 lines · Jingoo Han
Quoted 4 lines · Dan Carpenter
Return
-ENOMEMinstead of success ifioremap()fails.Signed-off-by Dan Carpenter <[email protected]>Reviewed-by Jingoo Han <[email protected]>Best regards,
Jingoo HanQuoted 3 lines
---
Static checker stuff, I can't compile this.
Quoted 9 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c static int hwicap_setup(struct device *dev, int id, · line 664
Quoted 9 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c +1
-0@@ -661,6 +661,7 @@ static int hwicap_setup(struct device *dev, int id, drvdata->base_address =ioremap (drvdata->mem_start, drvdata->mem_size);if (!drvdata->base_address) {dev_err (dev,"ioremap() failed\n" ); + retval = -ENOMEM ;
Isn't it just better to do?
if (IS_ERR(drvdata->base_address)) {
...
retval = PTR_ERR(drvdata->base_address);
}Thanks,
Michal
Quoted 27 lines · Michal Simek
Quoted 14 lines · Jingoo Han
Quoted 4 lines · Dan Carpenter
Return
-ENOMEMinstead of success ifioremap()fails.Signed-off-by Dan Carpenter <[email protected]>Reviewed-by Jingoo Han <[email protected]>Best regards,
Jingoo HanQuoted 3 lines
---
Static checker stuff, I can't compile this.Quoted 9 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c static int hwicap_setup(struct device *dev, int id, · line 664
Quoted 9 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c +1
-0@@ -661,6 +661,7 @@ static int hwicap_setup(struct device *dev, int id, drvdata->base_address =ioremap (drvdata->mem_start, drvdata->mem_size);if (!drvdata->base_address) {dev_err (dev,"ioremap() failed\n" ); + retval = -ENOMEM ;Isn't it just better to do?
Quoted 4 lines
if (IS_ERR(drvdata->base_address)) {
...
retval = PTR_ERR(drvdata->base_address);
}ioremap() returns NULL on error, not an ERR_PTR.
regards,
dan carpenter
Quoted 28 lines · Dan Carpenter
Quoted 27 lines · Michal Simek
Quoted 14 lines · Jingoo Han
Quoted 4 lines · Dan Carpenter
Return
-ENOMEMinstead of success ifioremap()fails.Signed-off-by Dan Carpenter <[email protected]>Reviewed-by Jingoo Han <[email protected]>Best regards,
Jingoo HanQuoted 3 lines
---
Static checker stuff, I can't compile this.Quoted 9 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c static int hwicap_setup(struct device *dev, int id, · line 664
Quoted 9 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c +1
-0@@ -661,6 +661,7 @@ static int hwicap_setup(struct device *dev, int id, drvdata->base_address =ioremap (drvdata->mem_start, drvdata->mem_size);if (!drvdata->base_address) {dev_err (dev,"ioremap() failed\n" ); + retval = -ENOMEM ;Isn't it just better to do?
Quoted 6 lines
Quoted 4 lines
if (IS_ERR(drvdata->base_address)) { ... retval = PTR_ERR(drvdata->base_address); }
ioremap()returns NULL on error, not anERR_PTR.
Ah ok. Fair enough.
Thanks,
Michal