Browse Source

MLK-14840: pinctrl: imx: fix resource leak

The device managed API actually not free the memory, so need
to use devm_kfree to free the memory to avoid leakage.

Coverity: 392384 resource leak

Signed-off-by: Peng Fan <peng.fan@nxp.com>
imx_v2017.03_4.9.11_1.0.0_ga
Peng Fan 4 years ago
parent
commit
aad973c1d7
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      drivers/pinctrl/nxp/pinctrl-imx.c

+ 5
- 0
drivers/pinctrl/nxp/pinctrl-imx.c View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Peng Fan <van.freenix@gmail.com>
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -53,6 +54,7 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct udevice *config)
if (fdtdec_get_int_array(gd->fdt_blob, node, "fsl,pins",
pin_data, size >> 2)) {
dev_err(dev, "Error reading pin data.\n");
devm_kfree(dev, pin_data);
return -EINVAL;
}
@ -78,6 +80,7 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct udevice *config)
if ((mux_reg == -1) || (conf_reg == -1)) {
dev_err(dev, "Error mux_reg or conf_reg\n");
devm_kfree(dev, pin_data);
return -EINVAL;
}
@ -166,6 +169,8 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct udevice *config)
}
}
devm_kfree(dev, pin_data);
return 0;
}


Loading…
Cancel
Save