Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1537861 > unrolled thread

[PATCH V1] acpi : nfit : core :- No need of devm functions

Started byArvind Yadav <arvind.yadav.cs@gmail.com>
First post2016-12-07 17:00 +0100
Last post2016-12-07 17:00 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH V1] acpi : nfit : core :- No need of devm functions Arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-07 17:00 +0100

#1537861 — [PATCH V1] acpi : nfit : core :- No need of devm functions

FromArvind Yadav <arvind.yadav.cs@gmail.com>
Date2016-12-07 17:00 +0100
Subject[PATCH V1] acpi : nfit : core :- No need of devm functions
Message-ID<sLMNs-1Yv-3@gated-at.bofh.it>
In function acpi_nfit_init_interleave_set, the memory allocated
for 'info' is live within the function only. After the allocation
it is immediately freed with devm_kfree. There is no need to
allocate memory for 'info' with devm function so replace
devm_kzalloc with kzalloc and devm_kfree with kfree.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/acpi/nfit/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 71a7d07..bd7e4e7 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1631,7 +1631,7 @@ static int acpi_nfit_init_interleave_set(struct acpi_nfit_desc *acpi_desc,
 	if (!nd_set)
 		return -ENOMEM;
 
-	info = devm_kzalloc(dev, sizeof_nfit_set_info(nr), GFP_KERNEL);
+	info = kzalloc(sizeof_nfit_set_info(nr), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 	for (i = 0; i < nr; i++) {
@@ -1644,6 +1644,7 @@ static int acpi_nfit_init_interleave_set(struct acpi_nfit_desc *acpi_desc,
 
 		if (!memdev || !nfit_mem->dcr) {
 			dev_err(dev, "%s: failed to find DCR\n", __func__);
+			kfree(info);
 			return -ENODEV;
 		}
 
@@ -1655,7 +1656,7 @@ static int acpi_nfit_init_interleave_set(struct acpi_nfit_desc *acpi_desc,
 			cmp_map, NULL);
 	nd_set->cookie = nd_fletcher64(info, sizeof_nfit_set_info(nr), 0);
 	ndr_desc->nd_set = nd_set;
-	devm_kfree(dev, info);
+	kfree(info);
 
 	return 0;
 }
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web