lib: devres: Add error information printing for __devm_ioremap_resource()
PATCH 1/1 lib: devres: Add error information printing for __devm_ioremap_resource()
Ensure that all error handling branches print error information. In this way, when this function fails, the upper-layer functions can directly return an error code without missing debugging information. Otherwise, the error message will be printed redundantly or missing.
--- lib/devres.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/devres.c +3 -1
@@ -157,8 +157,10 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, dev_name(dev), res->name); else pretty_name =devm_kstrdup (dev,dev_name (dev),GFP_KERNEL ); -if (!pretty_name) +if (!pretty_name) { +dev_err (dev,"can't generate pretty name for resource %pR\n" , res);return IOMEM_ERR_PTR (-ENOMEM ); + }if (!devm_request_mem_region (dev, res->start, size, pretty_name)) {dev_err (dev,"can't request region for resource %pR\n" , res);
Signature · 1 line
2.26.0.106.g9fadedd
Quoted 8 lines · Zhen Lei
Ensure that all error handling branches print error information. In this way, when this function fails, the upper-layer functions can directly return an error code without missing debugging information. Otherwise, the error message will be printed redundantly or missing.
Fixes 35bd8c07db2c ("devres: keep both device name and resource name in pretty name")Signed-off-by Zhen Lei <[email protected]>---
A Fixes: tag is probably a bit too drastic, but anyway:
Hi Zhen,
Quoted 7 lines · Zhen Lei
Ensure that all error handling branches print error information. In this way, when this function fails, the upper-layer functions can directly return an error code without missing debugging information. Otherwise, the error message will be printed redundantly or missing.
Fixes 35bd8c07db2c ("devres: keep both device name and resource name in pretty name")Signed-off-by Zhen Lei <[email protected]>
Thanks for your patch, which is now commit 5c3e241f5246445d ("lib:
devres: Add error information printing for __devm_ioremap_resource()") in driver-core-next.
lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 161
Quoted 9 lines
lib/devres.c +2
-1@@ -157,8 +157,10 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, dev_name(dev), res->name); else pretty_name =devm_kstrdup (dev,dev_name (dev),GFP_KERNEL ); -if (!pretty_name) +if (!pretty_name) { +dev_err (dev,"can't generate pretty name for resource %pR\n" , res);
If the above fails, it is due to a memory allocation failure, and the memory allocation core will have already printed an error message. So there is no need to print a second message.
Hence IMHO this commit should be reverted.
lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 166
Quoted 5 lines
lib/devres.c +1
-0return IOMEM_ERR_PTR (-ENOMEM ); + }if (!devm_request_mem_region (dev, res->start, size, pretty_name)) {dev_err (dev,"can't request region for resource %pR\n" , res);
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 15 lines · Geert Uytterhoeven
Hi Zhen,
Quoted 7 lines · Zhen Lei
Ensure that all error handling branches print error information. In this way, when this function fails, the upper-layer functions can directly return an error code without missing debugging information. Otherwise, the error message will be printed redundantly or missing.
Fixes 35bd8c07db2c ("devres: keep both device name and resource name in pretty name")Signed-off-by Zhen Lei <[email protected]>Thanks for your patch, which is now commit
5c3e241f5246445d("lib:
devres: Add error information printing for__devm_ioremap_resource()") in driver-core-next.
Quoted 14 lines
lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 161
Quoted 9 lines
lib/devres.c +2
-1@@ -157,8 +157,10 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, dev_name(dev), res->name); else pretty_name =devm_kstrdup (dev,dev_name (dev),GFP_KERNEL ); -if (!pretty_name) +if (!pretty_name) { +dev_err (dev,"can't generate pretty name for resource %pR\n" , res);If the above fails, it is due to a memory allocation failure, and the memory allocation core will have already printed an error message. So there is no need to print a second message.
Hence IMHO this commit should be reverted.
If the memory allocation fails, only the 'size' is printed, but the start address of the 'res' is not printed. So the printing here is not repeated. The start address is the more critical help information.
Quoted 11 lines
lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 166
Quoted 6 lines
lib/devres.c +1
-0return IOMEM_ERR_PTR (-ENOMEM ); + }if (!devm_request_mem_region (dev, res->start, size, pretty_name)) {dev_err (dev,"can't request region for resource %pR\n" , res);Gr{oetje,eeting}s,
Geert
Hi Leizhen,
Quoted 29 lines · Leizhen (ThunderTown)
Quoted 13 lines · Geert Uytterhoeven
Quoted 7 lines · Zhen Lei
Ensure that all error handling branches print error information. In this way, when this function fails, the upper-layer functions can directly return an error code without missing debugging information. Otherwise, the error message will be printed redundantly or missing.
Fixes 35bd8c07db2c ("devres: keep both device name and resource name in pretty name")Signed-off-by Zhen Lei <[email protected]>Thanks for your patch, which is now commit
5c3e241f5246445d("lib:
devres: Add error information printing for__devm_ioremap_resource()") in driver-core-next.Quoted 14 lines
lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 161
Quoted 9 lines
lib/devres.c +2
-1@@ -157,8 +157,10 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, dev_name(dev), res->name); else pretty_name =devm_kstrdup (dev,dev_name (dev),GFP_KERNEL ); -if (!pretty_name) +if (!pretty_name) { +dev_err (dev,"can't generate pretty name for resource %pR\n" , res);If the above fails, it is due to a memory allocation failure, and the memory allocation core will have already printed an error message. So there is no need to print a second message.
Hence IMHO this commit should be reverted.
Quoted 3 lines
If the memory allocation fails, only the 'size' is printed, but the start address of the 'res' is not printed. So the printing here is not repeated. The start address is the more critical help information.
Does that actually matter?
What can the user or developer do to fix this problem, with the additional knowledge of the resource's start address?
Quoted 5 lines
Quoted 5 lines
lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 166
Quoted 5 lines
lib/devres.c +1
-0return IOMEM_ERR_PTR (-ENOMEM ); + }if (!devm_request_mem_region (dev, res->start, size, pretty_name)) {dev_err (dev,"can't request region for resource %pR\n" , res);
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 33 lines · Geert Uytterhoeven
Hi Leizhen,
Quoted 29 lines · Leizhen (ThunderTown)
Quoted 27 lines · Geert Uytterhoeven
Quoted 7 lines · Zhen Lei
Ensure that all error handling branches print error information. In this way, when this function fails, the upper-layer functions can directly return an error code without missing debugging information. Otherwise, the error message will be printed redundantly or missing.
Fixes 35bd8c07db2c ("devres: keep both device name and resource name in pretty name")Signed-off-by Zhen Lei <[email protected]>Thanks for your patch, which is now commit
5c3e241f5246445d("lib:
devres: Add error information printing for__devm_ioremap_resource()") in driver-core-next.lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 161
Quoted 9 lines
lib/devres.c +2
-1@@ -157,8 +157,10 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, dev_name(dev), res->name); else pretty_name =devm_kstrdup (dev,dev_name (dev),GFP_KERNEL ); -if (!pretty_name) +if (!pretty_name) { +dev_err (dev,"can't generate pretty name for resource %pR\n" , res);If the above fails, it is due to a memory allocation failure, and the memory allocation core will have already printed an error message. So there is no need to print a second message.
Hence IMHO this commit should be reverted.
Quoted 7 lines
Quoted 3 lines
If the memory allocation fails, only the 'size' is printed, but the start address of the 'res' is not printed. So the printing here is not repeated. The start address is the more critical help information.
Does that actually matter?
What can the user or developer do to fix this problem, with the additional knowledge of the resource's start address?
Oh, you're right.
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 166
Quoted 6 lines
lib/devres.c +1
-0return IOMEM_ERR_PTR (-ENOMEM ); + }if (!devm_request_mem_region (dev, res->start, size, pretty_name)) {dev_err (dev,"can't request region for resource %pR\n" , res);Gr{oetje,eeting}s,
Geert