|
@@ -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);
|
|
|
+ void *ptr;
|
|
|
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 */
|
|
|
- pctl->functions = krealloc(pctl->functions,
|
|
|
- pctl->nfunctions * sizeof(*pctl->functions),
|
|
|
- GFP_KERNEL);
|
|
|
- if (!pctl->functions) {
|
|
|
+ ptr = krealloc(pctl->functions,
|
|
|
+ pctl->nfunctions * sizeof(*pctl->functions),
|
|
|
+ GFP_KERNEL);
|
|
|
+ if (!ptr) {
|
|
|
kfree(pctl->functions);
|
|
|
+ pctl->functions = NULL;
|
|
|
return -ENOMEM;
|
|
|
}
|
|
|
+ pctl->functions = ptr;
|
|
|
|
|
|
for (i = 0; i < pctl->desc->npins; i++) {
|
|
|
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
|