ARM: mmp: Fine-tuning for sram_probe()
Subsystems (4)
cover ARM: mmp: Fine-tuning for sram_probe()
From: Markus Elfring <[email protected]>
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(-)
Signature · 1 line
2.11.0
PATCH 1/2 ARM: mmp: Check return values from ioremap() and kstrdup() in sram_probe()
From: Markus Elfring <[email protected]>
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.
--- arch/arm/mach-mmp/sram.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
arch/arm/mach-mmp/sram.c +14 -3
@@ -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;
Signature · 1 line
2.11.0
PATCH 2/2 ARM: mmp: Delete an unnecessary variable initialisation in sram_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- arch/arm/mach-mmp/sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-mmp/sram.c +1 -1
@@ -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 ;
Signature · 1 line
2.11.0