Re: ARM-SMMU: Delete error messages for a failed memory allocation in three functions

2018-01-22 Thread SF Markus Elfring
>> Date: Sat, 20 Jan 2018 15:30:17 +0100
>>
>> Omit extra messages for a memory allocation failure in these functions.
> 
> Why?

Do you find the wording “WARNING: Possible unnecessary 'out of memory' message”
(from the script “checkpatch.pl”) more reasonable?


> This may as well be "delete some stuff because I feel like it".

Do you find the Linux allocation failure report insufficient
in this use case?

Regards,
Markus
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH] Intel-IOMMU: Delete an error message for a failed memory allocation in init_dmars()

2018-01-20 Thread SF Markus Elfring
>> Date: Sat, 20 Jan 2018 13:51:49 +0100
>>
>> Omit an extra message for a memory allocation failure in this function.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring 
> 
> NACK on this one and the other two IOMMU patches you sent.

Do you need any more background information for this general transformation 
pattern?


> The messages give the user/developer useful information about what the memory
> that failed to allocate would have been used for.

Do you find the Linux allocation failure report insufficient for this use case?

Regards,
Markus
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] ARM-SMMU: Delete error messages for a failed memory allocation in three functions

2018-01-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Jan 2018 15:30:17 +0100

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/arm-smmu-v3.c | 9 +++--
 drivers/iommu/arm-smmu.c| 9 +++--
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index f122071688fd..5c2a7103d494 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -2134,10 +2134,8 @@ static int arm_smmu_init_l1_strtab(struct 
arm_smmu_device *smmu)
void *strtab = smmu->strtab_cfg.strtab;
 
cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
-   if (!cfg->l1_desc) {
-   dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
+   if (!cfg->l1_desc)
return -ENOMEM;
-   }
 
for (i = 0; i < cfg->num_l1_ents; ++i) {
arm_smmu_write_strtab_l1_desc(strtab, &cfg->l1_desc[i]);
@@ -2828,10 +2826,9 @@ static int arm_smmu_device_probe(struct platform_device 
*pdev)
bool bypass;
 
smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL);
-   if (!smmu) {
-   dev_err(dev, "failed to allocate arm_smmu_device\n");
+   if (!smmu)
return -ENOMEM;
-   }
+
smmu->dev = dev;
 
if (dev->of_node) {
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 78d4c6b8f1ba..a4da4a870a2e 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -2048,10 +2048,9 @@ static int arm_smmu_device_probe(struct platform_device 
*pdev)
int num_irqs, i, err;
 
smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL);
-   if (!smmu) {
-   dev_err(dev, "failed to allocate arm_smmu_device\n");
+   if (!smmu)
return -ENOMEM;
-   }
+
smmu->dev = dev;
 
if (dev->of_node)
@@ -2084,10 +2083,8 @@ static int arm_smmu_device_probe(struct platform_device 
*pdev)
 
smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs,
  GFP_KERNEL);
-   if (!smmu->irqs) {
-   dev_err(dev, "failed to allocate %d irqs\n", num_irqs);
+   if (!smmu->irqs)
return -ENOMEM;
-   }
 
for (i = 0; i < num_irqs; ++i) {
int irq = platform_get_irq(pdev, i);
-- 
2.15.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] iommu/dmar: Delete an error message for a failed memory allocation in dmar_alloc_pci_notify_info()

2018-01-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Jan 2018 14:55:21 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/dmar.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 9a7ffd13c7f0..da6b121590cc 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -150,8 +150,6 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned 
long event)
} else {
info = kzalloc(size, GFP_KERNEL);
if (!info) {
-   pr_warn("Out of memory when allocating notify_info "
-   "for %s.\n", pci_name(dev));
if (dmar_dev_scope_status == 0)
dmar_dev_scope_status = -ENOMEM;
return NULL;
-- 
2.15.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] Exynos-IOMMU: Delete an error message for a failed memory allocation in exynos_iommu_init()

2018-01-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Jan 2018 14:28:13 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/exynos-iommu.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 79c45650f8de..456a88483089 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -1370,8 +1370,6 @@ static int __init exynos_iommu_init(void)
 
zero_lv2_table = kmem_cache_zalloc(lv2table_kmem_cache, GFP_KERNEL);
if (zero_lv2_table == NULL) {
-   pr_err("%s: Failed to allocate zero level2 page table\n",
-   __func__);
ret = -ENOMEM;
goto err_zero_lv2;
}
-- 
2.15.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] Intel-IOMMU: Delete an error message for a failed memory allocation in init_dmars()

2018-01-20 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 20 Jan 2018 13:51:49 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/intel-iommu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 4a2de34895ec..f4ba6bdf7863 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3258,7 +3258,6 @@ static int __init init_dmars(void)
g_iommus = kcalloc(g_num_of_iommus, sizeof(struct intel_iommu *),
GFP_KERNEL);
if (!g_iommus) {
-   pr_err("Allocating global iommu array failed\n");
ret = -ENOMEM;
goto error;
}
-- 
2.15.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] IPMMU-VMSA: Delete an error message for a failed memory allocation in ipmmu_probe()

2018-01-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 19 Jan 2018 22:22:38 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/ipmmu-vmsa.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 8dce3a9de9d8..1f78d60f2029 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -949,10 +949,8 @@ static int ipmmu_probe(struct platform_device *pdev)
int ret;
 
mmu = devm_kzalloc(&pdev->dev, sizeof(*mmu), GFP_KERNEL);
-   if (!mmu) {
-   dev_err(&pdev->dev, "cannot allocate device data\n");
+   if (!mmu)
return -ENOMEM;
-   }
 
mmu->dev = &pdev->dev;
mmu->num_utlbs = 32;
-- 
2.15.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] IOMMU-Tegra: gart: Delete two error messages for a failed memory allocation in tegra_gart_probe()

2018-01-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 19 Jan 2018 21:44:31 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/tegra-gart.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index b62f790ad1ba..1fee3a956832 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -419,10 +419,8 @@ static int tegra_gart_probe(struct platform_device *pdev)
}
 
gart = devm_kzalloc(dev, sizeof(*gart), GFP_KERNEL);
-   if (!gart) {
-   dev_err(dev, "failed to allocate gart_device\n");
+   if (!gart)
return -ENOMEM;
-   }
 
gart_regs = devm_ioremap(dev, res->start, resource_size(res));
if (!gart_regs) {
@@ -455,10 +453,8 @@ static int tegra_gart_probe(struct platform_device *pdev)
gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT);
 
gart->savedata = vmalloc(sizeof(u32) * gart->page_count);
-   if (!gart->savedata) {
-   dev_err(dev, "failed to allocate context save area\n");
+   if (!gart->savedata)
return -ENOMEM;
-   }
 
platform_set_drvdata(pdev, gart);
do_gart_setup(gart, NULL);
-- 
2.15.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH 2/2] lib: Improve a size determination in seven functions

2017-10-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 7 Oct 2017 19:19:45 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 lib/dma-debug.c | 2 +-
 lib/flex_array.c| 4 ++--
 lib/genalloc.c  | 2 +-
 lib/lru_cache.c | 2 +-
 lib/reed_solomon/reed_solomon.c | 2 +-
 lib/test_kmod.c | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index ea4cc3dde4f1..8b5c8fc76f8a 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -993,7 +993,7 @@ void dma_debug_add_bus(struct bus_type *bus)
if (dma_debug_disabled())
return;
 
-   nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
+   nb = kzalloc(sizeof(*nb), GFP_KERNEL);
if (nb == NULL) {
pr_err("dma_debug_add_bus: out of memory\n");
return;
diff --git a/lib/flex_array.c b/lib/flex_array.c
index 2eed22fa507c..ebe0f366b6cb 100644
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -102,7 +102,7 @@ struct flex_array *flex_array_alloc(int element_size, 
unsigned int total,
/* max_size will end up 0 if element_size > PAGE_SIZE */
if (total > max_size)
return NULL;
-   ret = kzalloc(sizeof(struct flex_array), flags);
+   ret = kzalloc(sizeof(*ret), flags);
if (!ret)
return NULL;
ret->element_size = element_size;
@@ -167,7 +167,7 @@ __fa_get_part(struct flex_array *fa, int part_nr, gfp_t 
flags)
 {
struct flex_array_part *part = fa->parts[part_nr];
if (!part) {
-   part = kmalloc(sizeof(struct flex_array_part), flags);
+   part = kmalloc(sizeof(*part), flags);
if (!part)
return NULL;
if (!(flags & __GFP_ZERO))
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 144fe6b1a03e..696cf1236b6c 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -153,7 +153,7 @@ struct gen_pool *gen_pool_create(int min_alloc_order, int 
nid)
 {
struct gen_pool *pool;
 
-   pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid);
+   pool = kmalloc_node(sizeof(*pool), GFP_KERNEL, nid);
if (pool != NULL) {
spin_lock_init(&pool->lock);
INIT_LIST_HEAD(&pool->chunks);
diff --git a/lib/lru_cache.c b/lib/lru_cache.c
index 28ba40b99337..4882ed22a8ce 100644
--- a/lib/lru_cache.c
+++ b/lib/lru_cache.c
@@ -116,7 +116,7 @@ struct lru_cache *lc_create(const char *name, struct 
kmem_cache *cache,
if (e_count > LC_MAX_ACTIVE)
return NULL;
 
-   slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL);
+   slot = kcalloc(e_count, sizeof(*slot), GFP_KERNEL);
if (!slot)
goto out_fail;
element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL);
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index 06d04cfa9339..2d0ec9f84322 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -70,7 +70,7 @@ static struct rs_control *rs_init(int symsize, int gfpoly, 
int (*gffunc)(int),
int i, j, sr, root, iprim;
 
/* Allocate the control structure */
-   rs = kmalloc(sizeof (struct rs_control), GFP_KERNEL);
+   rs = kmalloc(sizeof(*rs), GFP_KERNEL);
if (rs == NULL)
return NULL;
 
diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index 337f408b4de6..57f3337f2482 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -1086,7 +1086,7 @@ static struct kmod_test_device *alloc_test_dev_kmod(int 
idx)
struct kmod_test_device *test_dev;
struct miscdevice *misc_dev;
 
-   test_dev = vzalloc(sizeof(struct kmod_test_device));
+   test_dev = vzalloc(sizeof(*test_dev));
if (!test_dev)
goto err_out;
 
-- 
2.14.2

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH 1/2] lib/test: Delete five error messages for a failed memory allocation

2017-10-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 7 Oct 2017 17:34:23 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 lib/test_kasan.c | 5 ++---
 lib/test_kmod.c  | 8 ++--
 lib/test_list_sort.c | 9 +++--
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index a25c9763fce1..ef1a3ac1397e 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -353,10 +353,9 @@ static noinline void __init 
memcg_accounted_kmem_cache(void)
 */
for (i = 0; i < 5; i++) {
p = kmem_cache_alloc(cache, GFP_KERNEL);
-   if (!p) {
-   pr_err("Allocation failed\n");
+   if (!p)
goto free_cache;
-   }
+
kmem_cache_free(cache, p);
msleep(100);
}
diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index fba78d25e825..337f408b4de6 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -783,10 +783,8 @@ static int kmod_config_sync_info(struct kmod_test_device 
*test_dev)
free_test_dev_info(test_dev);
test_dev->info = vzalloc(config->num_threads *
 sizeof(struct kmod_test_device_info));
-   if (!test_dev->info) {
-   dev_err(test_dev->dev, "Cannot alloc test_dev info\n");
+   if (!test_dev->info)
return -ENOMEM;
-   }
 
return 0;
 }
@@ -1089,10 +1087,8 @@ static struct kmod_test_device *alloc_test_dev_kmod(int 
idx)
struct miscdevice *misc_dev;
 
test_dev = vzalloc(sizeof(struct kmod_test_device));
-   if (!test_dev) {
-   pr_err("Cannot alloc test_dev\n");
+   if (!test_dev)
goto err_out;
-   }
 
mutex_init(&test_dev->config_mutex);
mutex_init(&test_dev->trigger_mutex);
diff --git a/lib/test_list_sort.c b/lib/test_list_sort.c
index 28e817387b04..5474f3f3e41d 100644
--- a/lib/test_list_sort.c
+++ b/lib/test_list_sort.c
@@ -76,17 +76,14 @@ static int __init list_sort_test(void)
pr_debug("start testing list_sort()\n");
 
elts = kcalloc(TEST_LIST_LEN, sizeof(*elts), GFP_KERNEL);
-   if (!elts) {
-   pr_err("error: cannot allocate memory\n");
+   if (!elts)
return err;
-   }
 
for (i = 0; i < TEST_LIST_LEN; i++) {
el = kmalloc(sizeof(*el), GFP_KERNEL);
-   if (!el) {
-   pr_err("error: cannot allocate memory\n");
+   if (!el)
goto exit;
-   }
+
 /* force some equivalencies */
el->value = prandom_u32() % (TEST_LIST_LEN / 3);
el->serial = i;
-- 
2.14.2

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH 0/2] lib: Adjustments for 11 function implementations

2017-10-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 7 Oct 2017 19:39:29 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  test: Delete five error messages for a failed memory allocation
  Improve a size determination in seven functions

 lib/dma-debug.c |  2 +-
 lib/flex_array.c|  4 ++--
 lib/genalloc.c  |  2 +-
 lib/lru_cache.c |  2 +-
 lib/reed_solomon/reed_solomon.c |  2 +-
 lib/test_kasan.c|  5 ++---
 lib/test_kmod.c | 10 +++---
 lib/test_list_sort.c|  9 +++--
 8 files changed, 14 insertions(+), 22 deletions(-)

-- 
2.14.2

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] iommu/arm-smmu: Delete an unnecessary check before free_io_pgtable_ops()

2015-11-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 6 Nov 2015 18:32:41 +0100

The free_io_pgtable_ops() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/arm-smmu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 47dc7a7..1ce4b85 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -945,9 +945,7 @@ static void arm_smmu_destroy_domain_context(struct 
iommu_domain *domain)
free_irq(irq, domain);
}
 
-   if (smmu_domain->pgtbl_ops)
-   free_io_pgtable_ops(smmu_domain->pgtbl_ops);
-
+   free_io_pgtable_ops(smmu_domain->pgtbl_ops);
__arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx);
 }
 
-- 
2.6.2

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH 00/39] drop null test before destroy functions

2015-09-14 Thread SF Markus Elfring
> Recent commits to kernel/git/torvalds/linux.git have made the following
> functions able to tolerate NULL arguments:
>
> kmem_cache_destroy (commit 3942d29918522)
> mempool_destroy (commit 4e3ca3e033d1)
> dma_pool_destroy (commit 44d7175da6ea)

How do you think about to extend an other SmPL script?

Related topic:
scripts/coccinelle/free: Delete NULL test before freeing functions
https://systeme.lip6.fr/pipermail/cocci/2015-May/001960.html
https://www.mail-archive.com/cocci@systeme.lip6.fr/msg01855.html


> If these changes are OK, I will address the remainder later.

Would anybody like to reuse my general SmPL approach for similar source
code clean-up?

Regards,
Markus
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH] IOMMU-Tegra: gart: Delete an unnecessary check before the function call "vfree"

2015-07-09 Thread SF Markus Elfring
> From: Markus Elfring 
> Date: Thu, 5 Feb 2015 17:54:16 +0100
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/iommu/tegra-gart.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
> index f722a0c..07a795a 100644
> --- a/drivers/iommu/tegra-gart.c
> +++ b/drivers/iommu/tegra-gart.c
> @@ -404,8 +404,7 @@ static int tegra_gart_remove(struct platform_device *pdev)
>   struct gart_device *gart = platform_get_drvdata(pdev);
>  
>   writel(0, gart->regs + GART_CONFIG);
> - if (gart->savedata)
> - vfree(gart->savedata);
> + vfree(gart->savedata);
>   gart_handle = NULL;
>   return 0;
>  }
> 

Would you like to integrate this update suggestion
into another source code repository?

Regards,
Markus
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops"

2015-06-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 28 Jun 2015 15:55:11 +0200

The free_io_pgtable_ops() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/arm-smmu-v3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index f141301..8e9ec81 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1389,8 +1389,7 @@ static void arm_smmu_domain_free(struct iommu_domain 
*domain)
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
struct arm_smmu_device *smmu = smmu_domain->smmu;
 
-   if (smmu_domain->pgtbl_ops)
-   free_io_pgtable_ops(smmu_domain->pgtbl_ops);
+   free_io_pgtable_ops(smmu_domain->pgtbl_ops);
 
/* Free the CD and ASID, if we allocated them */
if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
-- 
2.4.4

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] IOMMU-Tegra: gart: Delete an unnecessary check before the function call "vfree"

2015-02-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Feb 2015 17:54:16 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/tegra-gart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index f722a0c..07a795a 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -404,8 +404,7 @@ static int tegra_gart_remove(struct platform_device *pdev)
struct gart_device *gart = platform_get_drvdata(pdev);
 
writel(0, gart->regs + GART_CONFIG);
-   if (gart->savedata)
-   vfree(gart->savedata);
+   vfree(gart->savedata);
gart_handle = NULL;
return 0;
 }
-- 
2.2.2

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"

2014-10-22 Thread SF Markus Elfring
>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From af73fb59d5d4b2c289fb236d0752522b6b38 Mon Sep 17 00:00:00 2001
From: Markus Elfring 
Date: Wed, 22 Oct 2014 19:39:21 +0200
Subject: [PATCH] IOMMU-MSM: Deletion of unnecessary checks before the function
 call "clk_disable"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring 
---
 drivers/iommu/msm_iommu.c | 3 +--
 drivers/iommu/msm_iommu_dev.c | 6 ++
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 6e3dcc28..3e4d888 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -73,8 +73,7 @@ fail:

 static void __disable_clocks(struct msm_iommu_drvdata *drvdata)
 {
-   if (drvdata->clk)
-   clk_disable(drvdata->clk);
+   clk_disable(drvdata->clk);
clk_disable(drvdata->pclk);
 }

diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c
index 61def7cb..9574d21 100644
--- a/drivers/iommu/msm_iommu_dev.c
+++ b/drivers/iommu/msm_iommu_dev.c
@@ -224,8 +224,7 @@ static int msm_iommu_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, drvdata);

-   if (iommu_clk)
-   clk_disable(iommu_clk);
+   clk_disable(iommu_clk);

clk_disable(iommu_pclk);

@@ -323,8 +322,7 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev)
SET_NSCFG(drvdata->base, mid, 3);
}

-   if (drvdata->clk)
-   clk_disable(drvdata->clk);
+   clk_disable(drvdata->clk);
clk_disable(drvdata->pclk);

dev_info(&pdev->dev, "context %s using bank %d\n", c->name, c->num);
-- 
2.1.2


___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu