git.samba.org
/
sfrench
/
cifs-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pinctrl: sunxi: Fix a memory leak in 'sunxi_pinctrl_build_state()'
[sfrench/cifs-2.6.git]
/
drivers
/
pinctrl
/
sunxi
/
pinctrl-sunxi.c
diff --git
a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 213a5d5d73f0034b243728e34f6fffcd62920d63..34e17376ef99ecd9e533d9346ca7145392d6b1c2 100644
(file)
--- a/
drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/
drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@
-1042,6
+1042,7
@@
static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
static int sunxi_pinctrl_build_state(struct platform_device *pdev)
{
struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
static int sunxi_pinctrl_build_state(struct platform_device *pdev)
{
struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
+ void *ptr;
int i;
/*
int i;
/*
@@
-1108,13
+1109,15
@@
static int sunxi_pinctrl_build_state(struct platform_device *pdev)
}
/* And now allocated and fill the array for real */
}
/* And now allocated and fill the array for real */
- p
ctl->functions
= krealloc(pctl->functions,
-
pctl->nfunctions * sizeof(*pctl->functions),
-
GFP_KERNEL);
- if (!p
ctl->functions
) {
+ p
tr
= krealloc(pctl->functions,
+ pctl->nfunctions * sizeof(*pctl->functions),
+ GFP_KERNEL);
+ if (!p
tr
) {
kfree(pctl->functions);
kfree(pctl->functions);
+ pctl->functions = NULL;
return -ENOMEM;
}
return -ENOMEM;
}
+ pctl->functions = ptr;
for (i = 0; i < pctl->desc->npins; i++) {
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
for (i = 0; i < pctl->desc->npins; i++) {
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;