* [PATCH 0/2] ARM: mmp: Fine-tuning for sram_probe()
@ 2016-12-03 16:57 SF Markus Elfring
2016-12-03 17:00 ` [PATCH 1/2] ARM: mmp: Check return values from ioremap() and kstrdup() in sram_probe() SF Markus Elfring
2016-12-03 17:02 ` [PATCH 2/2] ARM: mmp: Delete an unnecessary variable initialisation " SF Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2016-12-03 16:57 UTC (permalink / raw)
To: linux-arm-kernel, Eric Miao, Haojian Zhuang, Leo Yan, Russell King
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Dec 2016 17:50:23 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Check return values from ioremap() and kstrdup()
Delete an unnecessary variable initialisation
arch/arm/mach-mmp/sram.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] ARM: mmp: Check return values from ioremap() and kstrdup() in sram_probe()
2016-12-03 16:57 [PATCH 0/2] ARM: mmp: Fine-tuning for sram_probe() SF Markus Elfring
@ 2016-12-03 17:00 ` SF Markus Elfring
2016-12-03 17:02 ` [PATCH 2/2] ARM: mmp: Delete an unnecessary variable initialisation " SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2016-12-03 17:00 UTC (permalink / raw)
To: linux-arm-kernel, Eric Miao, Haojian Zhuang, Leo Yan, Russell King
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Dec 2016 17:26:32 +0100
Two return values were not checked before their further use so far.
This issue was detected by using the Coccinelle software.
* Add a bit of exception handling.
* Adjust tump targets.
Fixes: 3c7241bd36e2a618fe20c91f6c69cc20f2d981f2 ("ARM: mmp: add sram allocator")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/arm/mach-mmp/sram.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
index bf5e64906e65..0fbfc2a42ab3 100644
--- a/arch/arm/mach-mmp/sram.c
+++ b/arch/arm/mach-mmp/sram.c
@@ -88,14 +88,24 @@ static int sram_probe(struct platform_device *pdev)
info->sram_phys = (phys_addr_t)res->start;
info->sram_size = resource_size(res);
info->sram_virt = ioremap(info->sram_phys, info->sram_size);
+ if (!info->sram_virt) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
info->pool_name = kstrdup(pdata->pool_name, GFP_KERNEL);
+ if (!info->pool_name) {
+ ret = -ENOMEM;
+ goto unmap_io;
+ }
+
info->granularity = pdata->granularity;
info->gpool = gen_pool_create(ilog2(info->granularity), -1);
if (!info->gpool) {
dev_err(&pdev->dev, "create pool failed\n");
ret = -ENOMEM;
- goto create_pool_err;
+ goto free_name;
}
ret = gen_pool_add_virt(info->gpool, (unsigned long)info->sram_virt,
@@ -117,9 +127,10 @@ static int sram_probe(struct platform_device *pdev)
add_chunk_err:
gen_pool_destroy(info->gpool);
-create_pool_err:
- iounmap(info->sram_virt);
+free_name:
kfree(info->pool_name);
+unmap_io:
+ iounmap(info->sram_virt);
out:
kfree(info);
return ret;
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] ARM: mmp: Delete an unnecessary variable initialisation in sram_probe()
2016-12-03 16:57 [PATCH 0/2] ARM: mmp: Fine-tuning for sram_probe() SF Markus Elfring
2016-12-03 17:00 ` [PATCH 1/2] ARM: mmp: Check return values from ioremap() and kstrdup() in sram_probe() SF Markus Elfring
@ 2016-12-03 17:02 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2016-12-03 17:02 UTC (permalink / raw)
To: linux-arm-kernel, Eric Miao, Haojian Zhuang, Leo Yan, Russell King
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Dec 2016 17:38:21 +0100
The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/arm/mach-mmp/sram.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
index 0fbfc2a42ab3..260e8309dfd3 100644
--- a/arch/arm/mach-mmp/sram.c
+++ b/arch/arm/mach-mmp/sram.c
@@ -66,7 +66,7 @@ static int sram_probe(struct platform_device *pdev)
struct sram_platdata *pdata = pdev->dev.platform_data;
struct sram_bank_info *info;
struct resource *res;
- int ret = 0;
+ int ret;
if (!pdata || !pdata->pool_name)
return -ENODEV;
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-03 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-03 16:57 [PATCH 0/2] ARM: mmp: Fine-tuning for sram_probe() SF Markus Elfring
2016-12-03 17:00 ` [PATCH 1/2] ARM: mmp: Check return values from ioremap() and kstrdup() in sram_probe() SF Markus Elfring
2016-12-03 17:02 ` [PATCH 2/2] ARM: mmp: Delete an unnecessary variable initialisation " SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).