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


Groups > linux.kernel > #1538573

[PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions

From Arvind Yadav <arvind.yadav.cs@gmail.com>
Newsgroups linux.kernel
Subject [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions
Date 2016-12-08 15:40 +0100
Message-ID <sM81z-7fI-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


In functions pxa2xx_build_functions, the memory allocated for
'functions' is live within the function only. After the
allocation it is immediately freed with devm_kfree. There is
no need to allocate memory for 'functions' with devm function
so replace devm_kcalloc  with kcalloc and devm_kfree with kfree.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/pinctrl/pxa/pinctrl-pxa2xx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
index 866aa3c..47b8e3a 100644
--- a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
+++ b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
@@ -277,7 +277,7 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl)
 	 * alternate function, 6 * npins is an absolute high limit of the number
 	 * of functions.
 	 */
-	functions = devm_kcalloc(pctl->dev, pctl->npins * 6,
+	functions = kcalloc(pctl->npins * 6,
 				 sizeof(*functions), GFP_KERNEL);
 	if (!functions)
 		return -ENOMEM;
@@ -289,10 +289,12 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl)
 	pctl->functions = devm_kmemdup(pctl->dev, functions,
 				       pctl->nfuncs * sizeof(*functions),
 				       GFP_KERNEL);
-	if (!pctl->functions)
+	if (!pctl->functions) {
+		kfree(functions);
 		return -ENOMEM;
+	}
 
-	devm_kfree(pctl->dev, functions);
+	kfree(functions);
 	return 0;
 }
 
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions Arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-08 15:40 +0100
  Re: [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions Robin Murphy <robin.murphy@arm.com> - 2016-12-08 16:30 +0100
  Re: [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions Robin Murphy <robin.murphy@arm.com> - 2016-12-08 16:30 +0100
  Re: [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions Robert Jarzmik <robert.jarzmik@free.fr> - 2016-12-10 10:20 +0100
    Re: [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-11 09:10 +0100

csiph-web