> -----Original Message----- > From: Jagan Teki [mailto:[email protected]] > Sent: Thursday, May 11, 2017 5:18 PM > To: Peng Fan <[email protected]> > Cc: Simon Glass <[email protected]>; [email protected]; Stefan Agner > <[email protected]> > Subject: Re: [U-Boot] [PATCH] pinctrl: imx: fix memory leak > > On Thu, May 11, 2017 at 8:13 AM, Peng Fan <[email protected]> wrote: > > Each time set_state is called, a new piece memory will be allocated > > for pin_data, but not freed, this will incur memory leak. > > > > When error, the devm API could not free memory automatically. > > So need call devm_kfree when error. > > > > Issue reported by Coverity > > > > Signed-off-by: Peng Fan <[email protected]> > > Cc: Simon Glass <[email protected]> > > Cc: Stefan Agner <[email protected]> > > Cc: Stefano Babic <[email protected]> > > --- > > drivers/pinctrl/nxp/pinctrl-imx.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c > > b/drivers/pinctrl/nxp/pinctrl-imx.c > > index f0321c4..31a28e1 100644 > > --- a/drivers/pinctrl/nxp/pinctrl-imx.c > > +++ b/drivers/pinctrl/nxp/pinctrl-imx.c > > @@ -53,6 +53,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(pin_data); > > we need to specify the pointer from where to free?
Oh. Missed to add dev pointer here. Thanks, Peng. > > thanks! > -- > Jagan Teki > Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream > Maintainer Hyderabad, India. _______________________________________________ U-Boot mailing list [email protected] https://lists.denx.de/listinfo/u-boot

