usb: dwc3: Free resource immediately after use
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 27 Mar 2019 15:17:37 +0000 (17:17 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Fri, 3 May 2019 06:13:48 +0000 (09:13 +0300)
When we read an array of integers from device properties,
the temporary buffer is allocated.

However, in case of dwc3_set_incr_burst_type() it's not freed.
Free allocated buffer immediately after use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/core.c

index a1b126f90261e3cb328669fe7843ee14ad39faa0..f8d3d352581328fd7b1c0927fccb1cbec6562f49 100644 (file)
@@ -828,6 +828,7 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
        ret = device_property_read_u32_array(dev,
                        "snps,incr-burst-type-adjustment", vals, ntype);
        if (ret) {
+               kfree(vals);
                dev_err(dev, "Error to get property\n");
                return;
        }
@@ -846,6 +847,8 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
                incrx_mode = INCRX_BURST_MODE;
        }
 
+       kfree(vals);
+
        /* Enable Undefined Length INCR Burst and Enable INCRx Burst */
        cfg &= ~DWC3_GSBUSCFG0_INCRBRST_MASK;
        if (incrx_mode)