MLK-21911 drm/bridge: sec-dsim: free 'pll_pms' to avoid memory leak
The 'pll_pms' data is allocated dynamically and it should be
freed after its usage is done explicitly, otherwise there is
a serious memory leak problem, since this data allocation
frequency is really high during video playback and graphic
cases running.
BUG: 146221914
Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
(cherry picked from commit f28801c464ac6d43893584af85bc348e66149e9d)
Change-Id: Ib12984d9a03caa64dc6035d54b89daef0083317e
diff --git a/drivers/gpu/drm/bridge/sec-dsim.c b/drivers/gpu/drm/bridge/sec-dsim.c
index 0fa4e09..f0b9032 100644
--- a/drivers/gpu/drm/bridge/sec-dsim.c
+++ b/drivers/gpu/drm/bridge/sec-dsim.c
@@ -1241,8 +1241,10 @@ struct dsim_pll_pms *sec_mipi_dsim_calc_pmsk(struct sec_mipi_dsim *dsim)
}
}
- if (best_delta == ~0U)
+ if (best_delta == ~0U) {
+ devm_kfree(dev, pll_pms);
return ERR_PTR(-EINVAL);
+ }
pll_pms->p = best_p;
pll_pms->m = best_m;
@@ -1294,6 +1296,11 @@ int sec_mipi_dsim_check_pll_out(void *driver_private,
PLLCTRL_SET_M(pmsk->m) |
PLLCTRL_SET_S(pmsk->s);
+ /* free 'dsim_pll_pms' structure data which is
+ * allocated in 'sec_mipi_dsim_calc_pmsk()'.
+ */
+ devm_kfree(dsim->dev, (void *)pmsk);
+
if (dsim->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) {
hpar = sec_mipi_dsim_get_hblank_par(mode->name,
mode->vrefresh,