From aad973c1d782f12128eca14214b11b08d2a7f1f7 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Wed, 10 May 2017 08:44:04 +0800 Subject: 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 --- drivers/pinctrl/nxp/pinctrl-imx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c b/drivers/pinctrl/nxp/pinctrl-imx.c index 9b80d50..e29e241 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx.c +++ b/drivers/pinctrl/nxp/pinctrl-imx.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2016 Peng Fan + * 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; } -- cgit v1.1